Optimize my code =)

bearophile bearophileHUGS at lycos.com
Mon Feb 17 15:46:31 PST 2014


Kapps:

> I remember array operations (such as data[] -= other.data[]) 
> being significantly slower than doing it yourself. I don't know 
> if this has been fixed.

They are not being "fixed". But for arrays as large as the ones 
here, they are fast enough.

---------------------

I have tested the code (all in a single module) using the latest 
dmd and ldc2 (beta versions in both cases), compiling with:

dmd -O -release -inline -noboundscheck matrix.d
ldmd2 -O -release -inline -noboundscheck matrix.d


Best timings:

LDC2:

multiplicationTest ...
         Time required: 2 secs, 522 msecs

DMD:

multiplicationTest ...
         Time required: 4 secs, 724 msecs

Using link-time optimization, or using AVX/AVX2 on modern CPUs 
(using the compiler switcher for the AVX) could improve the LDC2 
timings a little more.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list