Good demo for showing benefits of parallelism

Jascha Wetzel "[firstname]" at mainia.de
Mon Jan 29 14:13:51 PST 2007


Frits van Bommel wrote:
> It's probably related to the [Qo[0],Qo[1],Qo[2]] expression, which
> allocates a 3-element array _on the heap_. AFAIK to allocate on the
> heap a mutex needs to be locked, which might explain bad threading
> behavior.

yep, that's exactly what happens.
An array literal alwyas gets allocated on the heap by _d_arrayliteral,
which uses new, which in turn uses GC.malloc, which locks a mutex.
It shouldn't render a problem if there are some allocs, but those were
definitely too many...

I removed the unnessecary use of array literals, and now everything runs
the way it should.
Now i get 9.940sec with one thread and 5.011sec with two (opteron dual
core 2.6ghz), which stays about the same for higher thread counts. Nice! :)

So here is, for your parallel raytracing pleasure, the little demo as
intended in the first place:
http://mainia.de/prt.zip



More information about the Digitalmars-d mailing list