challenge #3 - Parallel for loop

Mikola Lysenko mclysenk at mtu.edu
Sat Jan 27 14:21:31 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
> }
> 
> //Example 2
> int sum = 0;
> for_parallel(int a; a<array.length; ++a) //These could be anything
> {
>   sum += array[a];   //This could be anything
> }
> 
> 1) The call syntax is a simple generic one statement.
> 2) It needs to represent a foreach/for-loop as close as possible, 
> although it doesn't need to look like a D foreach/for-loop.
> 3) It needs to handle things like adding all the parts in an array (this 
> is the difficult part).
> 4) Since foreach_parallel always works on an array, you may take some 
> concessions for this loop, taking the array of operation into account 
> (ie, you may split the array).
> 5) If we can't do it, what syntax would you recommend to close this gap?
> 
> -Joel


http://www.assertfalse.com/downloads/dcsp-alpha0.zip

-Mik



More information about the Digitalmars-d mailing list