mercredi 5 octobre 2016

C++ RNG: how to get different rand generators on different processors?

How do I seed the random generator so that I have different number sequences on different processors?

My first attempt was using the processor's rank as seed. Then I found out the hard way that srand(0) gives the same sequence as srand(1).

Currently, I'm doing this:

srand(time(NULL) + rank)

Is this an OK approach? Or is there a better way? Thanks




Aucun commentaire:

Enregistrer un commentaire