I need some help benchmarking SoA vs AoS
ag0aep6g via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Mar 26 10:04:45 PDT 2016
On 26.03.2016 17:31, ag0aep6g wrote:
> Let the output depend on the results somehow. Simply printing them out
> should do the trick. You can also try throwing an Exception on wrong
> results. Else the calculations will be optimized away completely.
>
> Also make sure that data that's supposed to be dynamic actually comes
> from some kind of input. Else the program may just print precalculated
> results.
I've crudely applied my advise here:
https://gist.github.com/aG0aep6G/a1b87df1ac5930870ffe/revisions
(Can I somehow link to one specific commit of a gist?)
size is now read from the program arguments instead of being an enum,
and the results are checked with enforce. ldmd can no longer avoid
calculating anything or precalculate the results completely.
It may still do ridiculous optimizations that wouldn't be possible with
real world data, because the data is so formulaic. To avoid that you
could prepare a file with test data and read it from there in the
benchmark program. That way ldmd can't make predictions about it.
Note that I quick-and-dirty worked around two correctness issues in your
code:
1) SOA didn't set its length. I've added it to allocate. No idea if
that's the right spot.
2) SOA doesn't set the correct initial values. I'm just setting them
from the outside here.
More information about the Digitalmars-d-learn
mailing list