[Rcpp-devel] Mersenne Twister in RcppArmadillo?
Simon Zehnder
szehnder at uni-bonn.de
Sun Feb 10 09:50:36 CET 2013
Dear Yan, dear Dirk,
thank you for these very precise answers! I think at the beginning I'll fall back to the R RNG. I will test if it is faster to create an Armadillo vector/matrix and fill it via R::rnorm, or if it is faster to use Rcpp sugar and change the Rcpp::NumericVector to an arma::vec via arma::conv_to.
Btw Dirk, this is a nice overview given at the Rcpp gallery for timing random number generators.
Your HPC library Random123 looks pretty interesting to me. I am very into HPC and use openMP and OpenMPI a lot. In this case however, I have to use specifically a Mersenne Twister RNG, as I want to compare results from my older simulation package, using Scythe Statistical Library, and my newer one using RcppArmadillo. As Scythe uses MT, I want to use the same RNG and same seed to have results comparable to each other.
Later on, when I know all results are plausible, I will concentrate on speed.
Best
Simon
On Feb 9, 2013, at 5:42 PM, Yan Zhou <zhouyan at me.com> wrote:
>>
>> This really is a BIG topic and worth a few more comments. Note that I wrote a
>> few related posts on RNGs at the Rcpp Gallery, see for example
>>
>> http://gallery.rcpp.org/articles/timing-normal-rngs/
>>
>> which compares the RNGs from R, C++11 and Boost. Simon just added Armadillo to
>> the list, we can add even more RNGs fromn other packages.
>
> If it is of interest to anyone, I once timed Boost, C++11 and Random123 (A high performance parallel RNG, http://www.thesalmons.org/john/random123/releases/latest/docs/, It come with a C++11 compatible RNG engine, can be used just like std::mt19937) once for different compilers on Linux. I just uploaded them to https://github.com/zhouyan/vSMC/wiki/RNG-performance-comparison
>
> There are two benchmark, one for the performance of URNG (mt19937 etc). These include those in C++11 <random> and Boost.Random, which are almost identical in functionality (C++11 <random> is based on Boost.Random after all). Also they include two URNG from Random123, threefry and philox (both come with four basic configurations)
>
> Another benchmark is the performance of generating distribution random numbers (such as normal). The Random123 threefry2x64 was used for all distribution and compilers, since it is the one with least performance difference between compilers.
>
> Compilers include,
> clang SVN with libstdc++ 4.7
> clang SVN with libc++ SVN
> gcc 4.7
> intel icpc 13
>
> clang and gcc version also come with results when using AMD libm instead of glibc. However, the benchmark are not Rcpp specific. They are compiled to standalone C++ programs. But all these URNGs can be used Rcpp. As demonstrated in Dirk's example.
>
> Best,
>
> Yan Zhou
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20130210/2594f5a8/attachment.html>
More information about the Rcpp-devel
mailing list