I apologize if this is in the documentation somewhere and I've missed it.
Searches involving the words "chapel" and "private" are turning up a lot of
non-programming related web pages :-(

I'm working on parallelizing a code that includes a two-dimensional loop
nest (call it "i" and "j"), in which each iteration of the i loop defines
all elements of a vector v and then later uses that vector, e.g. something
like this (may contain typos, I just entered this in my email to give the
idea):

   var v:[0..m-1] real(64);

   for i in 0 .. n-1 {
      for j in 0 .. m-1 {
         ...
         v[j] = ...
      }

      ..  // lots of other computation

      for j in 0 .. m-1 {
        ... use of v[j]
      }
    }


v is not used anywhere else. I'd like to make the i loop into a "forall",
but of course then there will be races on v.

I'm guessing that I could just put the declaration of v iside the i loop,
to get a separate vector for each thread? However, I'm doing some kind of
strange things with iterators and classes, trying to abstract away some
aspects of how things are stored, so it might be nicer to leave the
definition of v outside of the loop nest (though, with just the code above,
I agree that doing so not only is ugly but raises semantic issues about the
value of v after the end of the i loop). I could also have an array than I
index by "i", thus "expanding" rather than "privatizing" v.

At the moment, we're exploring a lot of options, so my question is whether
there are any other options beyond these two (#1 = put v inside the i loop,
#2 = subscript by i as well as v). Possibly locale's would be interesting?
That's on my "to learn" list, so maybe it's time.

Dave W
_______________________________________________
Chapel-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-users

Reply via email to