<div dir="ltr">Dear Rcpp developers,<div><br></div><div> I am working on a small package (<a href="https://github.com/mfasiolo/mvn">here</a>) that should provide efficient tools </div><div>for the multivariate normal distribution using Rcpp/RcppArmadillo and OpenMP.</div>
<div> </div><div>Creating functions that evaluate the multivariate normal density efficiently</div><div>was fairly straightforward, but I am struggling with parallel random number</div><div>generation with OpenMP.</div><div>
<br></div><div>As I understand, doing things such as:</div><div><br></div><div><div>NumericMatrix out(n, d);</div><div>#pragma omp for schedule(static)<br></div><div>for(int kk = 0; kk < d; kk++) out( _, kk) = rnorm(n);</div>
</div><div><br></div><div>is not going to work, because rnorm() is not thread safe </div><div>(in fact this code crashed R). On the other hand R level parallelism</div><div>using clusterApply, mclapply etc appears to be too slow to be of any</div>
<div>use for this purpose.</div><div><br></div><div>Is anybody aware of any package providing a parallel C++ rng which my</div><div>package might link to? I have read <a href="http://www.lindonslog.com/programming/parallel-random-number-generation-trng/">this post</a> about Tina's rng, which</div>
<div>seems to work with OpenMP and Rcpp. How hard would it be to have</div><div>such a library included in my package (if at all possible)?</div><div><br></div><div>Sorry for the possibly silly questions and thanks for any suggestion.</div>
<div><br></div><div>Matteo</div></div>