Finding large difference b/w execution time of c++ and D codes for same problem

Marco Leise Marco.Leise at gmx.de
Wed Feb 13 10:29:50 PST 2013


Am Wed, 13 Feb 2013 18:10:47 +0100
schrieb Joseph Rushton Wakeling <joseph.wakeling at webdrake.net>:

> Just to update on times.  I was running another large job at the same time as 
> doing all these tests, so there was some slowdown.  Current results are:
> 
> -- with g++ -O3 and using double rather than float: about 4.3 s
> 
> -- with clang++ -O3 and using double rather than float: about 3.1 s
> 
> -- with gdmd -O -release -inline:
> 
>      D code serial with dimension 32768 ...
>        using floats Total time: 17.179 [sec], Julia value: 0
>        using doubles Total time: 10.298 [sec], Julia value: 0
>        using reals Total time: 17.126 [sec], Julia value: 0
> 
> -- with ldmd2 -O -release -inline:
> 
>      D code serial with dimension 32768 ...
>        using floats Total time: 3.548 [sec], Julia value: 0
>        using doubles Total time: 2.708 [sec], Julia value: 0
>        using reals Total time: 4.371 [sec], Julia value: 0
> 
> -- with dmd -O -release -inline:
> 
>      D code serial with dimension 32768 ...
>        using floats Total time: 15.696 [sec], Julia value: 0
>        using doubles Total time: 7.233 [sec], Julia value: 0
>        using reals Total time: 28.71 [sec], Julia value: 0
> 
> You'll note that I added a writeout of the global juliaValue in order to check 
> that certain calculations weren't being optimized away.
> 
> It's striking that in this case GDC is slower not only than LDC but also DMD. 
> Current GDC is based off 2.060 as far as I know, whereas current LDC has 
> upgraded to 2.061, so are there some changes between D 2.060 and 2.061 that 
> could explain this?

???
Anyways I upgraded to LLVM 3.2 - no change. You have an i7, I
have a Core2. It would be really interesting to know what LDC
does there. Since GDC's output seems rather CPU agnostic and
LDC's output is better in every case but also exhibits system
specific details so harshly I would never have imagined
possible. Should Intel have changed their CPU design so
radically?

> It's also interesting that clang++ produces a faster executable than g++, but 
> it's not possible to make a direct LLVM vs GCC comparison here, as g++ is GCC 
> 4.7.2 whereas GDC is based off a GCC snapshot.

I've compiled GDC based on the same source that the Gentoo
package manager built G++ 4.7.2 from and, I get similar
numbers.

> My guess would be that it's some combination of LLVM superiority in a particular 
> case here, together with some 2.060 --> 2.061.
> 
> Are these results comparable to what other people are getting?
> 
> I can confirm that where code of mine is concerned, GDC still seems to have the 
> edge in terms of executable speed ...

I've seen a tête à tête between LDC and GDC in some of my
code.

-- 
Marco



More information about the Digitalmars-d-learn mailing list