D slower than C++ by a factor of _two_ for simple raytracer (gdc)

downs default_357-line at yahoo.de
Thu Feb 14 18:29:55 PST 2008


My platform is GDC 4.1.2 vs G++ 4.1.1.

I played around with the simple ray tracer code I'd ported to D a while back, still being dissatisfied with the timings of 21s (D) vs 16s (C++).

During this, I found a nice optimization that brought my D code down to 17s, within less than a second of C++!

"Glee" I thought!

Then I applied the same optimization to the C++ source and it dropped to 8s.

I haven't been able to get the D code even close to this new speed level.

The outputs of both programs are identical save for off-by-one differences.

The source code for the C++ version is http://paste.dprogramming.com/dpvpm7jv

D version is http://paste.dprogramming.com/dpzal0jd

Before you ask, yes I've tried turning the structs into classes, the classes into structs and the refs into pointers. That usually made no difference, or worsened it.

Both programs were built with -O3 -ffast-math, the D version additionally with -frelease.
Both compilers were built with roughly similar configure flags. The GDC used is the latest available in SVN, and based on DMD 1.022.

Does anybody know how to bring the D results in line with, or at least closer to, the C++ version?

Ideas appreciated,

 --downs



More information about the Digitalmars-d mailing list