What's the "right" way to do openmp-style parallelism?

Dominikus Dittes Scherkl via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Sep 8 00:33:03 PDT 2015


On Tuesday, 8 September 2015 at 05:50:30 UTC, Russel Winder wrote:
>     void main() {
>       immutable imax = 10;
>       immutable jmax = 10;
>       float[imax][jmax] x;
>       foreach(int j; 1..jmax){
>         foreach(int i, ref item; parallel(x[j-1])){
>           x[j][i] = complicatedFunction(i, item);
>         }
>       }
>     }
>
> (though sadly, this doesn't compile for a reason I can't fathom 
> instantly)
Hmm. Shouldn't you instead parallel the outer loop?



More information about the Digitalmars-d-learn mailing list