Benchmarking mir.ndslice + lubeck against numpy and Julia

Joseph Rushton Wakeling joseph.wakeling at
Mon Jan 13 11:51:20 UTC 2020

On Saturday, 11 January 2020 at 21:54:13 UTC, p.shkadzko wrote:
> Today I decided to write a couple of benchmarks to compare D 
> mir with lubeck against Python numpy, then I also added Julia 
> snippets. The results appeared to be quite interesting.

Thanks for running these benchmarks.  A few notes/questions that 
may be interesting:

(1) Do I understand right that both numpy and lubeck just call 
into external linear algebra libraries (BLAS and LAPACK) for the 
actual number crunching?  (I believe so.)

(2) Assuming that is true, then compiler flags will probably only 
make a difference to the initialization and allocation of the 
matrices.  (IIRC, Xorshift's performance is very different when 
optimized versus un-optimized.)  That likely explains why D and 
Python performance are near-identical once matrix initialization 
is taken out of the equation: the actual number-crunching is 
being done by the same external libraries.

(3) The much speedier Julia results can probably be explained by 
its use of dedicated data structures for various stages of 
calculation, see §5.2 of

(4) Just as a general remark for your original benchmarks: while 
obviously a "just getting started" comparison is perfectly valid, 
it's unlikely you're comparing like with like.  Leaving aside the 
compiler optimization flags, odds are that e.g. the randomized 
initialization of matrix elements is being done very differently 
in the 3 different languages (probably a different underlying RNG 
in each case, and quite possibly some extra tricks in numpy and 
Julia to handle the case of randomly initializing the contents of 
an entire matrix or array).

**Principal takeaway**: anyone who wants to match Julia for speed 
needs to follow its lead in terms of dedicated data structures 
for linear algebra, not just hook into long-running standards 
like BLAS and LAPACK.  There are opportunities here for libmir :-)

More information about the Digitalmars-d mailing list