One thing we can do is use SFMT Jump. It's dependencies are not so 
straightforward to build, and I am not sure how well supported this is, but 
it may be the best way to get parallel streams.

http://www.math.sci.hiroshima-u.ac.jp/~%20m-mat/MT/SFMT/JUMP/index.html

-viral

On Wednesday, July 16, 2014 10:31:35 AM UTC+5:30, Andreas Noack wrote:
>
> You'll have to set the seed on each process, i.e. fetch 2 srand(1); fetch 
> 3 srand(2); However, I am not sure what our random number generator (dsfmt) 
> promises about independence of the different streams. We should look into 
> that to ensure that you get good random number when running in parallel.
>
>
> 2014-07-15 23:25 GMT+01:00 Gray Calhoun <[email protected]>:
>
>> Hi everyone, I'm trying to start using Julia for some Monte Carlo 
>> simulations
>> (not MCMC) which I'd like to parallelize. I haven't found any 
>> documentation
>> for setting the RNG's seed for parallelization. The naive approach gives
>> different results than non-parallel execution (which is not surprising).
>>
>> Starting with `julia -p 4` and executing:
>>
>>     ## Sequential execution
>>     srand(1)
>>     seqfor = Array(Float64,4)
>>     for i=1:4
>>         seqfor[i] = rand()
>>     end
>>
>>     ## Parallel execution
>>     srand(1)
>>     parfor = @parallel (vcat) for i=1:4
>>         rand()
>>     end
>>
>>     [sort(parfor) sort(seqfor)]
>>
>> gives
>>
>>     4x2 Array{Float64,2}:
>>      0.346517  0.00790928
>>      0.346517  0.236033
>>      0.662369  0.312707
>>      0.914194  0.346517
>>
>> and re-running the parallel code can give different results even after
>> re-seeding. If we start julia without `-p 4` then both loops give the
>> same results. If it matters, I'm using Julia version 0.3.0-rc1+28
>> from source (commit 79e4771).
>>
>> Is there documentation on the right way to parallelize simulations in
>> Julia? If not, should my next step be to carefully read the "parallel
>> computing" documentation?
>>
>
>
>
> -- 
> Med venlig hilsen
>
> Andreas Noack Jensen
>  

Reply via email to