N-body bench
Stanislav Blinov
stanislav.blinov at gmail.com
Thu Jan 30 13:26:15 PST 2014
On Thursday, 30 January 2014 at 21:04:06 UTC, bearophile wrote:
> Stanislav Blinov:
>
>> Unrolling everything except the loop in energy() seems to have
>> squeezed the bits neede to outperform c++, at least on my
>> machine :)
>
> That should be impossible, as I remember from my old profilings
> that energy() should use only an irrelevant amount of run time.
I meant that if I unroll it, it's not irrelevant anymore :)
> While I benchmark some variants of this program I am seeing a
> large variety of problems, limitations, bugs and regressions...
:)
> You latest D code crashes my ldc2 V.0.12.1, while 0.13.0-alpha1
> compiles it.
:))
> My older version of your D code runs with both compiler
> versions, but V.0.12.1 generates faster code.
:)))
> Plus you can't make those double2 immutable, you can't use
> vector ops (because of performance, and also because they
> aren't nothrow in V.0.12.1).
Well, not being able to make them immutable is not *that* big of
a problem now, is it? What would be actually cool to have are
those slice operations.
> I was also experimenting with (note the align):
>
> align(16) struct Body {
> double[3] x, v;
> double mass;
> }
>
> struct NBodySystem {
> private:
> __gshared static Body[5] bodies = [
> // Sun.
> Body([0., 0., 0.],
> [0., 0., 0.],
> solarMass),
Yeah... I've even thrown away that filler in the latest version
:o)
> But this improves the code for V.0.12.1 and worsens it for
> 0.13.0-alpha1.
%|
>> (I'm sticking to atoi because my copy of ldc seems to have an
>> issue in std.conv).
>
> My version seems to use to!() correctly.
I'm using the git head (704ab3, last commit Sun Jan 26 00:00:21).
I haven't tried the release yet.
> If ldc2 developers are reading this thread there is enough
> strange stuff here to give one or two headaches :-)
Indeed.
> Now I don't know what "final" version should I keep of this
> program :-)
I was going to compare the asm listings, but C++ seems to have
unrolled and inlined the outer loop right inside main(), and now
I'm slightly lost in it :)
More information about the Digitalmars-d-learn
mailing list