Good demo for showing benefits of parallelism

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Sat Jan 27 16:24:07 PST 2007


Philipp Spöth wrote:
> I did the good, old, elaborate "remove/insert everything until you
> locate the problem" technique. And finaly speed improoved to about 9,6
> seconds for the testscene with one thread (down from 39 seconds).
> Also threading behaviour is reasonable now. Two threads do the job
> in 5,4 seconds.
> 
> I had to change a couple of things. To many to list here, but when
> the following lines are in - the strange threading behaviour is in as well:
> 
> Vec4d	Qo;
> [snip]
> Vec3d Qo3;
> Qo3 = [Qo[0],Qo[1],Qo[2]];
> 
> 
> When the last line is replaced with these - everything is fine:
> Qo3[0] = Qo[0];
> Qo3[1] = Qo[1];
> Qo3[2] = Qo[2];
> 
> 
> So the problem seems to be related to the vector assign operator

I don't think it is, at least not directly. 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.



More information about the Digitalmars-d mailing list