Actually there are two problems with this code:
-
MersenneTwister()
does not ensure that PRNGs are non-overlapping (although the risk of overlap is very small - but this is the reason whyrandjump
is provided) - The simplest you can do is either do
deepcopy
in each thread an element used by this thread of an array of initiated PRNGs in a single thread or use a “separator” object (one PRNG that is discarded to separate data in threads) similarly to what I proposed in KissThreading.jl/KissThreading.jl at master · mohamed82008/KissThreading.jl · GitHub. The discarding approach might not be best if you have NUMA issues in your infrastructure.