On 04/06/11 20:16, simendsjo wrote:
On 04.06.2011 20:04, Timon Gehr wrote:
ulong SumMultiple3Or5_parallel(uint below) {
ulong sum;
foreach(i; parallel(iota(below))) {
if(i % 3 == 0 || i % 5 == 0)
sum += i; // low level data race here.
}
return sum;
}

Loop iterations in a parallel foreach loop must be independent of each
other.


I thought paralellism was using locks behind the scenes. Guess I'll have
to read the documentation then :)

You can always try reduce and map :) I can't remember whether they are parallel or not though!

Reply via email to