The PRNG I wrote has a period of 2^64. When I use a spinlock to protect it from 4 threads, It runs twice slower than when there is a single thread. A mutex appears better at making things slower. So I decided to have separate generators per thread, but the problem here is that when the seeds are too close, The same series of random numbers will appear again and again each in a different thread. I'm not 100% sure how bad this will affect my simulation, but I'd like to avoid having very closely seeded PRNGs.
The best I can think of is like below, with 4 threads.
N = 2 ^ 64 / 4 (^ means power)
n = getSomeNiceInitialSeed()
seed1 = n
seed2 = n + N
seed3 = n + N * 2
seed4 = n + N * 3
Is there some better solution to this problem?
Aucun commentaire:
Enregistrer un commentaire