Matrix Multiplication benchmark

bearophile bearophileHUGS at lycos.com
Thu Aug 16 09:52:33 PDT 2012


RommelVR:

opMul is obsolete, I suggest to use the newer operator
overloading.

> Why this huge difference in performance?

I don't know, why don't you show us the minimized but compilable
source code of the two versions plus their clean assembly (so
using printf instead of writeln, etc)? Sometimes it's hard to
micro optimize for performance if you don't see the asm.


Matthias Pleh:

> I suggest changing 'in' to 'const ref' for a real boost; though 
> the semantic difference between the two isn't exactly clear to 
> me in the documentation.

"in" expands in "scope const". So both are const, but scope is
about not escaping data, while ref means the 64 bytes of the
struct are passed by reference, this means by pointer. With 64
bytes it's probably better to use ref.

In Ada there is something like a "smart_ref" that uses ref or
not, choosing what's the most efficient of the two in the current
case (it's not good to interface with C code).

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list