Template error and parallel foreach bug?
simendsjo
simen.endsjo at pandavre.com
Sat Jun 4 12:16:03 PDT 2011
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 :)
More information about the Digitalmars-d-learn
mailing list