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

Daniel Lewis murpsoft at hotmail.com
Thu Feb 14 22:05:24 PST 2008


downs Wrote:

> 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

Don't have a GC, or statically load all of Phobos just to do simple raytracing?



More information about the Digitalmars-d mailing list