Re: [Rcpp-devel] Parallel random numbers using Rcpp and OpenMP

2014-04-30 Thread Matteo Fasiolo
Hi Mark, many thanks for all the info, I will certainly have a detailed look at what you are doing. I think it would be nice to have a package that uses C++ level parallelism (OpenMP or not) to speed up random number generation at R level. For example: > library("microbenchmark") > library("mvtn

Re: [Rcpp-devel] Parallel random numbers using Rcpp and OpenMP

2014-04-30 Thread Mark Clements
My two cents worth: For the microsimulation package, we needed uniform random number streams and sub-streams at the C++ level, while supporting R's non-uniform random number distributions[*]. For this, we used the C++ RngStreams library and provided "double *user_unif_rand ()" for user-defined RNG

Re: [Rcpp-devel] Parallel random numbers using Rcpp and OpenMP

2014-04-28 Thread Romain Francois
Hi, If you can assume c++11, you might bot need openmp, as you can just use standard support for threads, etc ... Although the compiler suite used on windows (if you care about that) does not support c++11 threads. This might be available later. Romain Le 28 avr. 2014 à 12:51, Matteo Fasi

Re: [Rcpp-devel] Parallel random numbers using Rcpp and OpenMP

2014-04-28 Thread Matteo Fasiolo
Hi all, many thanks for your detailed replies, I see that there are many options out there. As a first step I think I will try out the C++11 option that Matt suggested, as it seems relatively simple. In particular I might do something like: #pragma omp parallel { std::mt19937_64 engine(

Re: [Rcpp-devel] Parallel random numbers using Rcpp and OpenMP

2014-04-28 Thread Matt D.
On 4/28/2014 01:30, Matteo Fasiolo wrote: [...] As I understand, doing things such as: NumericMatrix out(n, d); #pragma omp for schedule(static) for(int kk = 0; kk < d; kk++) out( _, kk) = rnorm(n); is not going to work, because rnorm() is not thread safe (in fact this code crashed R). On the

Re: [Rcpp-devel] Parallel random numbers using Rcpp and OpenMP

2014-04-27 Thread Dirk Eddelbuettel
Matteo, On 28 April 2014 at 01:30, Matteo Fasiolo wrote: | Dear Rcpp developers, | |  I am working on a small package (here) that should provide efficient tools  | for the multivariate normal distribution using Rcpp/RcppArmadillo and OpenMP. |   | Creating functions that evaluate the multivaria