i use in my program boost uniform distribution between 0 and 1:
#include <boost/random/uniform_01.hpp>
#include <boost/random.hpp>
static boost::mt19937 rng;
static boost::uniform_01<boost::mt19937&> zeroone(rng);
zeroone() function is called inside a for-loop which i would like to parallel, using OpenMP.
for ( int index = 0 ; index < 4096 ; index++ ) {
if ( node[ index ] == false ) {
if ( zeroone() < 0.03 )
node[ index ] = true;
}
}
The question if it is possible using OpenMP to parallel the for-loop and not damaging the uniform distribution pseudorandom number generator?
e.g. Is it possible to define for the first core a seed, for the second core the corresponding seed that the first core pseudorandom number generator will reach after 6 times?
Regards
You can do what you suggest, but
You can give each thread it’s own private RNG (seed each one independently). The uniform distribution property will still hold unless your dataset is really small (in which case, the uniformness would be swamped by the sample noise anyway, regardless of threads)
My scheme would look something like this: