On Tue, 2015-09-08 at 07:33 +0000, Dominikus Dittes Scherkl via
Digitalmars-d-learn wrote:
> 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?

Can't do that because it is a pipeline: the current computation is
input to the next one. As far as I can tell there is no way the code as
presented can be parallelized in the general case. If there were some
guarantees on complicatedFunction, then it is a different game.

-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.win...@ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: rus...@winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to