Template error and parallel foreach bug?
Ben Grabham
Evil.Nebster at gmail.com
Sat Jun 4 19:56:25 PDT 2011
On 05/06/11 03:55, Ben Grabham wrote:
> 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!
Oops, sorry, missed the bit where you said you've already done parallel map!
More information about the Digitalmars-d-learn
mailing list