On Wednesday, July 16, 2014 12:07:09 AM UTC-5, James Delaney wrote:

If your goal is that each call to rand(), regardless of process, 
>
sequentially pulls a number from the RNG stream, then perhaps 
>
you just need to create a MersenneTwister([seed]) object.
>
> mystream = MersenneTwister(1)
>  ## Parallel execution
>     srand(1)
>     parfor = @parallel (vcat) for i=1:4
>         rand(mystream)
>     end
>

Thanks for the reply. This is probably close to what I'll end up
doing.  The execution time of each simulation is long enough that it
should dwarf any communication overhead, and I'd (ideally) like the
results to be independent of the number of processors used, which this
accomplishes.

Unfortunately the code doesn't work as written. With four processors,
it returns

    julia> parfor
    4-element Array{Float64,1}:
     0.236033
     0.236033
     0.236033
     0.236033

I'll look into what's going on more carefully, because it would be
nice to have an approach like this work. (I assume `mystream` is
copied into each process, which `pmap` should be able to avoid.)

--Gray

--
Gray Calhoun Assistant Professor of Economics, Iowa State University
http://gray.clhn.co // (515) 294-6271 // 467 Heady Hall

Reply via email to