Fast multidimensional Arrays

Ilya Yaroshenko via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Aug 29 09:15:32 PDT 2016


On Monday, 29 August 2016 at 15:46:26 UTC, Steinhagelvoll wrote:
> On Monday, 29 August 2016 at 14:55:50 UTC, Seb wrote:
>> On Monday, 29 August 2016 at 14:43:08 UTC, Steinhagelvoll 
>> wrote:
>>> It is quite surprising that there is this much of a 
>>> difference, even when all run sequential. I believe this 
>>> might be specific to this small problem.
>>
>> You should definitely have a look at this benchmark for matrix 
>> multiplication across a many languages:
>>
>> https://github.com/kostya/benchmarks#matmul
>>
>> With the recent generic GLAS kernel in mir, matrix 
>> multiplication in D is the blazingly fast (it improved the 
>> existing results by at least 8x).
>> Please not that this requires the latest LDC beta with 
>> includes the fastMath pragma and GLAS is still under 
>> development at mir:
>>
>> https://github.com/libmir/mir
>
> It not really about multiplying matrices. I wanted to see how D 
> compares for different tasks. If I actually want to do matrix 
> multiplication I will  use LAPACK or something of that nature.
>
> In this task the difference was much bigger compared to e.g. 
> prime testing, which was about even.

ndslice is analog of numpy. It is more flexible comparing with 
Fortran arrays. In the same time, if you want fast iteration 
please use Mir, which includes upcoming ndslice.algorithm with 
@fasmath attribute and `vectorized` flag for `ndReduce`. Note, 
that in-memory representation is important for vectorization, 
e.g. for dot product both slices should have strides equal to 1. 
Add also -mcpu=native flag for LDC.

http://docs.mir.dlang.io/latest/mir_ndslice_algorithm.html#ndReduce

Best regards,
Ilya


More information about the Digitalmars-d-learn mailing list