Hello,

I've come across the library experimental.ndslice, which is supposed to mimic NumPy. In order to test it I wrote a very crude matrix multiplication:

http://pastebin.com/Ew4u2iVz

and for comparison I also implemented it in Fortran90:

http://pastebin.com/6afnVyZF

Then I used linux's "time" command to time them each:

ifort test.f90 && time ./a.out
         600

real    0m0.154s
user    0m0.148s
sys     0m0.004s


dmd test.d  && time ./test
1.16681e+08
600   600

real    0m6.770s
user    0m6.772s
sys     0m0.004s


I understand that dmd is not optimized for speed, but in the end both do basically the same thing. Both implement 2D array and both array types include the size of the array (unlike C). Given that both are compiled languages the difference seems to be unreasonably large.

If I turn on boundschecking for Fortran I get:

ifort -check all test.f90 && time ./a.out
         600

real    0m6.049s
user    0m6.044s
sys     0m0.004s


which is roughly the speed difference I'd expect, but if I use the -boundscheck=off option for dmd that doesn't help. Am I using ndslice correctly? Why is the speed difference so large? How do I speed it up?

Kind regards

Matthias

_______________________________________________
phobos mailing list
phobos@puremagic.com
http://lists.puremagic.com/mailman/listinfo/phobos

Reply via email to