Using the boost random number generator with OpenMP -


I want to parallel my drop random number generator code in C ++ with OpenMP. I want to do it in a manner that is both efficient and thread safe, does anyone signal to me how it is done? I am currently locking down which is below; This thread is not obviously secure because there is the possibility of running the race in a stable variable normal function in the sample. The number of samples (nsamples) is much higher than n.

  #pragma omp parallel private (i, j) (i = 0; i & lt; nsamples; i ++) to {(J = 0; j & lt; n ; J ++) {Random matrix [i + nsamples * j] = sample normal (0.0, 1.0); }} Double sampling normal (mean repeating dual sigma) {// Create a Merson Twister random number generator stable Mtl9937 Rng (Static_cast and lt; unsigned> (std :: time (0)); // choose Gaussian probability distribution Samany_distrybandi & lt; Double & gt; Norm_dist (mean, sigma); // separate random number generator to distribution variate_generator & lt; mt19937 & amp ;, General_ distribution & lt; Double & gt; & Gt; Samany_samplr (Aranji, Man_dist); // Distribution from normal to normal Moine (sample);}  

Do you just need something that secures the thread Is it good or something? If you do not need too much performance in your PRNG, then you can wrap the lock around the use of the rng object. For high performance, you have a parallel The pseudo random number generator needs to be found or written - they have a tutorial on them. Idiosyncrasies storage will have an option to your mt19937 put objects in, make sure to seed different threads with different seeds; Which reproduces similar results in different runs, if it is important for you.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -