I've read that, in order to ensure thread safety, it's convenient to seed the RNG
inside the parallel region like this:
int seedbase = 392872;
#pragma omp parallel
{
srand(omp_get_thread_id * seedbase);
#pragma omp for
....
}
But what if my parallelized section is inside another loop? If I had a situation like this:
int seedbase = 392872;
for(int i=0; i<100; ++i)
{
#pragma omp parallel
{
srand(omp_get_thread_id * seedbase);
#pragma omp for
....
}
}
Where should I initialize my RNG
?