Function rng_set_seed (o2scl)¶
-
void o2scl::rng_set_seed(rng<> &r, int mpi_size = 1, int mpi_rank = 0, int verbose = 0)¶
Set the RNG seed using an OpenMP critical block.
This function sets the random number seed for the given random number generator. If OpenMP support is included when O2scl is compiled, then the seed generation is enclosed in an OpenMP critical block to ensure that multiple threads do not get the same seed. This function uses the variable lib_settings_class::seed to store a global library seed.
When OpenMP is enabled, it is possible that this function could create a condition where no OpenMP thread can proceed and thus prevent subsequent code from running as normal, however, this is expected to be rare in practice.
Note
This function currently uses the number 1000001 as a number to separate MPI ranks, an algorithm which can be foiled if one selects more than 1000000 random numbers for each MPI rank. In practice this should be rare, as seed selection should happen more rarely.