Looking for writing parallel foreach kind of statement for nested for-loops
FG
home at fgda.pl
Sat Feb 9 15:09:04 PST 2013
On 2013-02-09 23:32, Sparsh Mittal wrote:
> I saw foreach and parallel commands on
> http://dlang.org/phobos/std_parallelism.html
>
> I have nested for-loops as follows:
>
> for(int i=1; i< N; i++)
> {
> for(int j=1; j < M; j++)
> {
> func(i,j);
> }
> }
>
> Here func(i,j) is such that there is no dependency or communication b/w
> different (i,j) tuple values. Thus, problem is very simple.
Huh?
for(int i=1; i< N; i++) <==> foreach(i; iota(1, N))
so you can use: foreach(i; parallel(iota(1, N))) { ... }
More information about the Digitalmars-d-learn
mailing list