challenge #3 - Parallel for loop
Andrei Alexandrescu (See Website For Email)
SeeWebsiteForEmail at erdani.org
Fri Jan 26 12:29:16 PST 2007
janderson wrote:
> I would like to be able to run a for loop in parallel, using syntax like:
>
> //example 1
> int sum = 0;
> foreach_parallel(int a; array)
> {
> sum += array[a]; //This could be anything
> }
This challenge "is not like the others". Unfortunately parallelization
like the above is not going to be done soon. Parallelizing arbitrary
serial code is an active research topic that has not been settled.
In particular, notice that even your simple example requires serious
smarts from a compiler, because it features dependencies across the
loop: sum can be apparently updated on the n+1'th iteration only after
it has been updated on the n'th iteration.
Andrei
More information about the Digitalmars-d
mailing list