www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - path tracing benchmark

reply Trass3r <un known.com> writes:
I ported smallpt to D some time ago and now that I've working versions of  
LDC2 and GDC2 I did a quick comparison:

Original code:
http://kevinbeason.com/smallpt/explicit.cpp

D version:
https://bitbucket.org/trass3r/smallptd/src


C++ -- g++ -O3 explicit.cpp:

Rendering (4 spp) 100.00%
real	0m28.477s
user	0m26.470s
sys	0m0.160s

D -- dmd -release -O -inline -noboundscheck smallpt.d -ofsmallptDMD:
real	1m32.687s
user	1m30.820s
sys	0m0.300s

D -- gdc -frelease -fno-bounds-check -O3 smallpt.d -o smallptGDC:
real	0m52.598s
user	0m48.900s
sys	0m0.150s

D -- ldc2 -O3 -release -enable-inlining smallpt.d -ofsmallptLDC:
real	0m39.622s
user	0m36.100s
sys	0m0.240s
Aug 07 2011
parent reply bearophile <bearophileHUGS lycos.com> writes:
Trass3r:

 I ported smallpt to D some time ago and now that I've working versions of  
 LDC2 and GDC2 I did a quick comparison:

I have converted to D many of the commonly found benchmarks, this is my version: http://codepad.org/ZbmSfseY If I compile it with with LDC1 with Link Time Optimization + Interning: ldc -O3 -release -inline -output-bc smallpt2_d.d opt -std-compile-opts smallpt2_d.bc > smallpt2_do.bc llvm-ld -native -ltango-base-ldc -ltango-user-ldc -ldl -lm -lpthread -internalize-public-api-list=_Dmain -o=smallpt2_do smallpt2_do.bc I produce a binary that's faster than the C++ version (22.7 seconds instead of 29 seconds). Bye, bearophile
Aug 07 2011
next sibling parent %u <me emails.com> writes:
This is off topic but if you're interested you can get it to run using
float if you change the Sphere code to:

FP eps = 1e-2; instead of 1e-4;
Aug 08 2011
prev sibling next sibling parent reply Christian Kamm <kamm-incasoftware removethis.de> writes:
bearophile wrote:

 Trass3r:
 
 I ported smallpt to D some time ago and now that I've working versions of
 LDC2 and GDC2 I did a quick comparison:

I have converted to D many of the commonly found benchmarks, this is my version: http://codepad.org/ZbmSfseY If I compile it with with LDC1 with Link Time Optimization + Interning: ldc -O3 -release -inline -output-bc smallpt2_d.d opt -std-compile-opts smallpt2_d.bc > smallpt2_do.bc llvm-ld -native -ltango-base-ldc -ltango-user-ldc -ldl -lm -lpthread -internalize-public-api-list=_Dmain -o=smallpt2_do smallpt2_do.bc I produce a binary that's faster than the C++ version (22.7 seconds instead of 29 seconds).

bearophile, just out of interest, what's the performance like if you ran ldmd -O3 -release -inline smallpt2_d.d ? If everything worked right -std- compile-opts should do the same that LDC does at -O3. And why would internalizing _Dmain have a noticable performance impact?
Aug 09 2011
parent reply bearophile <bearophileHUGS lycos.com> writes:
Christian Kamm:

 bearophile, just out of interest, what's the performance like if you ran 
 ldmd -O3 -release -inline smallpt2_d.d ?

I don't remember what ldmd is. Without LTO the performance of the LDC compile was a bit lower than the G++ compile.
 And why would internalizing _Dmain have a noticable performance impact?

It's the only way I have found to perform link-time-optimization with LDC1. It assumes the whole program is compiled at once, so it's able to perform more cross optimizations. Bye, bearophile
Aug 09 2011
parent Jacob Carlborg <doob me.com> writes:
On 2011-08-09 22:04, bearophile wrote:
 Christian Kamm:

 bearophile, just out of interest, what's the performance like if you ran
 ldmd -O3 -release -inline smallpt2_d.d ?

I don't remember what ldmd is. Without LTO the performance of the LDC compile was a bit lower than the G++ compile.

ldmd is a wrapper that converts dmd arguments to ldc arguments. So you can call ldc with the same arguments you would call dmd. -- /Jacob Carlborg
Aug 09 2011
prev sibling next sibling parent reply Trass3r <un known.com> writes:
 If I compile it with with LDC1 with Link Time Optimization + Interning:
 ldc -O3 -release -inline -output-bc smallpt2_d.d

 opt -std-compile-opts smallpt2_d.bc > smallpt2_do.bc

 llvm-ld -native -ltango-base-ldc -ltango-user-ldc -ldl -lm -lpthread  
 -internalize-public-api-list=_Dmain -o=smallpt2_do smallpt2_do.bc

Is there a more convenient way to get LTO with LDC?
Aug 10 2011
parent reply bearophile <bearophileHUGS lycos.com> writes:
Trass3r:

 Is there a more convenient way to get LTO with LDC?

This is the best/only one I have found for LDC1. Feel free to search for something better/shorter (and tell me if you find it, please). Bye, bearophile
Aug 10 2011
parent reply Robert Clipsham <robert octarineparrot.com> writes:
On 10/08/2011 14:49, Trass3r wrote:
 LDC does have -O4 and -O5 switches but they probably don't work?!

Had a quick look at the source, no indications that -O4 and O5 do anything more than -O3.

They don't, there's no way to do LTO built into LDC. I seem to recall some conversation about adding it, I may just be remembering this thread though *g* -- Robert http://octarineparrot.com/
Aug 10 2011
parent Robert Clipsham <robert octarineparrot.com> writes:
On 10/08/2011 17:43, Trass3r wrote:
 Am 10.08.2011, 18:16 Uhr, schrieb Robert Clipsham
 <robert octarineparrot.com>:
 On 10/08/2011 14:49, Trass3r wrote:
 Had a quick look at the source, no indications that -O4 and O5 do
 anything more than -O3.

They don't, there's no way to do LTO built into LDC. I seem to recall some conversation about adding it, I may just be remembering this thread though *g*

Why is there no way?

Patches welcome ;)
 Can't LDC be modified to support gold+plugin just like clang?

Of course it can - I said "built into", not "in". The only reason it's not there is because no one has written support for it. -- Robert http://octarineparrot.com/
Aug 10 2011
prev sibling next sibling parent Trass3r <un known.com> writes:
Am 10.08.2011, 14:54 Uhr, schrieb bearophile <bearophileHUGS lycos.com>:

 Trass3r:

 Is there a more convenient way to get LTO with LDC?

This is the best/only one I have found for LDC1. Feel free to search for something better/shorter (and tell me if you find it, please).

Well, obviously you need to install the gold linker and that llvm plugin. But I don't know how to go on after that. LDC does have -O4 and -O5 switches but they probably don't work?!
Aug 10 2011
prev sibling next sibling parent Trass3r <un known.com> writes:
 LDC does have -O4 and -O5 switches but they probably don't work?!

Had a quick look at the source, no indications that -O4 and O5 do anything more than -O3.
Aug 10 2011
prev sibling parent Trass3r <un known.com> writes:
Am 10.08.2011, 18:16 Uhr, schrieb Robert Clipsham  
<robert octarineparrot.com>:
 On 10/08/2011 14:49, Trass3r wrote:
 Had a quick look at the source, no indications that -O4 and O5 do
 anything more than -O3.

They don't, there's no way to do LTO built into LDC. I seem to recall some conversation about adding it, I may just be remembering this thread though *g*

Why is there no way? Can't LDC be modified to support gold+plugin just like clang?
Aug 10 2011