Check out SharedArrays.

--Tim

On Thursday, March 12, 2015 04:56:12 PM Pieter Barendrecht wrote:
> I'm wondering how to save data/results in a parallel for-loop. Let's assume
> there is a single Int64 array, initialised using zeros() before starting
> the for-loop. In the for-loop (typically ~100,000 iterations, that's the
> reason I'm interested in parallel processing) the entries of this Int64
> array should be increased (based on the results of an algorithm that's
> invoked in the for-loop).
> 
> Everything works fine when using just a single proc, but I'm not sure how
> to modify the code such that, when using e.g. addprocs(4), the data/results
> stored in the Int64 array can be processed once the for-loop ends. The
> algorithm (a separate function) is available to all procs (using the
> require() function). Just using the Int64 array in the for-loop (using
> @parallel for k=1:100000) does not work as each proc receives its own copy,
> so after the for-loop it contains just zeros (as illustrated in a set of
> slides on the Julia language). I guess it involves @spawn and fetch()
> and/or pmap(). Any suggestions or examples would be much appreciated :).

Reply via email to