Re: Looking for writing parallel foreach kind of statement for nested for-loops

2013-02-10 Thread Sparsh Mittal
Think again if you need that. Things start getting pretty ugly. :) Yes, it is not at all intuitive. Indeed... Sparsh, any reason you need the calculation to be done on 2d blocks instead of independent slots? For my problem, original answer was fine, since parallel calculations are not at

Re: Looking for writing parallel foreach kind of statement for nested for-loops

2013-02-10 Thread Philippe Sigaud
On Sun, Feb 10, 2013 at 8:45 AM, FG wrote: > On 2013-02-10 02:22, Sparsh Mittal wrote: >> >> The current reply answers my question, but I was just curious. Can we have >> a >> method which divides the 2d region as follows: 8*12 divided into 4*6 to >> each of >> 4 threads. > > > Think again if you

Re: Looking for writing parallel foreach kind of statement for nested for-loops

2013-02-09 Thread FG
On 2013-02-10 02:22, Sparsh Mittal wrote: The current reply answers my question, but I was just curious. Can we have a method which divides the 2d region as follows: 8*12 divided into 4*6 to each of 4 threads. Think again if you need that. Things start getting pretty ugly. :) const uint pa

Re: Looking for writing parallel foreach kind of statement for nested for-loops

2013-02-09 Thread Sparsh Mittal
for(int i=1; i< N; i++)<==>foreach(i; iota(1, N)) so you can use: foreach(i; parallel(iota(1, N))) { ... } Thanks a lot. This one divides the x-cross-y region by rows. Suppose dimension is 8*12 and 4 parallel threads are there, so current method is dividing by 2*12 to each of 4 thread

Re: Looking for writing parallel foreach kind of statement for nested for-loops

2013-02-09 Thread FG
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 dep