How interesting. This was the exact same example I discovered to help 
develop my first parallel simulation.
The key take away for me was splitting into two files:

Tip: For parallel processing in Julia, separate your code into two files, 
one file containing the functions and parameters that need to be run in 
parallel, and the other file managing the processing and collecting 
results. Use the *require* command in the managing file to import the 
functions and parameters to all processors.

Originally the "required" file (that runs on all processors) seeded the RNG 
(`srand(2)`), which I thought was odd. As Andreas pointed out, this just 
means you'll run the same thing n times on n workers.
So I changed it to srand(seed + myid()), which is pretty much equivalent to 
Andreas':
for p in workers() @spawnat p srand(seed + p) end


Would that be to get the exact same variates as the serial execution would 
> create?


Well for me, I want "random" seeding but with reproducibility.
Mostly I want "randomly"-seeded random sims, rather than predetermined 
(which doesn't seem very random). But I want the ability to rerun with same 
seed if required)
For serial execution I could achieve this by seeding with say the current 
time, and outputting the seed with the sim results.
For parallel, I could do similar, say <current time> + <worker id>
But there is the question of RNG stream independence (apparently more so 
when the seeds are very similar).
So jump ahead would be ideal in my case, effectively allowing independent, 
parallel random seeding, but with reproducibility.

Reply via email to