RNG Streaming Force Security

I have a loop that should be well parallelized by inserting one openmp pragma:

  boost::normal_distribution<double> ddist(0, pow(retention, i - 1));
  boost::variate_generator<gen &, BOOST_TYPEOF(ddist)> dgen(rng, ddist);
  // Diamond                                                                
  const std::uint_fast32_t dno = 1 << i - 1;
// #pragma omp parallel for
  for (std::uint_fast32_t x = 0; x < dno; x++)
    for (std::uint_fast32_t y = 0; y < dno; y++)
      {
        const std::uint_fast32_t diff = size/dno;
        const std::uint_fast32_t x1 = x*diff, x2 = (x + 1)*diff;
        const std::uint_fast32_t y1 = y*diff, y2 = (y + 1)*diff;
        double avg =
          (arr[x1][y1] + arr[x1][y2] + arr[x2][y1] + arr[x2][y2])/4;
        arr[(x1 + x2)/2][(y1 + y2)/2] = avg + dgen();
      }

(if I don’t make a mistake, each execution is independent of the others at all. Sorry that not all the code is inserted).

Be that as it may, my question is to increase the reliability of the RNG? They seem to reference the gcc code for gcc, so even if gcc code is thread safe, this may not be the case for other platforms.

+4
source share
2 answers

Viewing the archives of the Boost mailing list gives:

Boost.Random does not support global states that need protection against multithreading.

Boost.Random , - . ( , ). , .

+6

, boost, TRNG. TINA . . , TRNG OpenMP http://www.lindonslog.com/programming/parallel-random-number-generation-trng/ , . , , , . .

+1

All Articles