[phobos] Ndslice speed
Martin Nowak via phobos
phobos at puremagic.com
Thu Dec 29 17:34:47 PST 2016
On 08/27/2016 09:43 PM, Matthias Redies via phobos wrote:
> 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:
Posting a reply from Ilya here:
Hi Matthias,
It is incorrect to compare the same code for ndslice and fortran because:
1. current ndslice is numpy like vectors (matrixes are always has both
string and raw strides).
2. m[i, j] can not be vectrized for non-strided vectors too because D
language constraint: D has not macros engine; operator overloading for
[i, j] destruct vectorisation for LDC and GDC.
You can achieve the same speed as fortran if you will use
mir.ndslice.algorithm [1]. It is available at [3] (with mir.ndslice).
The blog post is about mir.ndslice.algorithm can be found at [2]. An LDC
compiler should be used (DMD is supported but it is too slow).
We are working on new version of ndslice, which will include classic
BLAS-like matrixes, and will simplify mir.ndslice.algorithm logic [4]
(it is still can not be used, will be released during one month). With
new ndslice m[i, j] will be still slow, however indexing as m[i][j] will
be fast as fortran.
In general forward access (front/popFront) is more user-friendly for
vectorisation then random access (indexing like [i, j]).
Please use mir.ndslice.algorithm for now.
Best regards,
Ilya
[1] http://docs.mir.dlang.io/latest/mir_ndslice_algorithm.html
[2]
http://blog.mir.dlang.io/ndslice/algorithm/optimization/2016/12/12/writing-efficient-numerical-code.html
[3] https://github.com/libmir/mir
[4] https://github.com/libmir/mir-algorithm
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 839 bytes
Desc: OpenPGP digital signature
URL: <http://lists.puremagic.com/pipermail/phobos/attachments/20161230/62b4764a/attachment.sig>
More information about the phobos
mailing list