Version: 1.0
Download
Release Date: 6/7/2013
Version 1.0 of OMPRNG has been significantly rewritten to make use of C++ classes and objects. Although the syntax is now slightly different, this change has made using OMPRNG even easier than version 0.2. In addition, maintenance and updates will be easier with the new architecture. Enjoy!
OMPRNG is a parallel random number generator for C++. It uses
While there are other parallel RNG's such as SPRNG and PURG, these are much more difficult to implement then OMPRNG. In addition, I have found that Hyperthreading (found on Intel's newest chips) can cause problems with parallel RNG's (I have noted problems w/ both PURG and RNGStreams) if not carefully implemented. OMPRNG properly handles Hyperthreading.
Random numbers can be generated from the following statistical distributions
See the omprng.h file for details.
Three files are provided to demonstrate the usage of OMPRNG:
To compile the program on Linux, you need
The matrix software package "Eigen" (http://eigen.tuxfamily.org) is also included in the OMPRNG package; it is used for the multivariate normal distribution.
Users have reported that OMPRNG can be compilied and run on OS-X as well.
Download omprng.zip to a local directory. To compile, do the following:
Three executable programs are provided: "pi", "test", and "test-mvn". To run, type
The OMPRNG code is contained in the "omprng.h" file. The .cpp files demonstrate how to use OMPRNG. In the pi.cpp file, for example, the parallel RNG is initialized by a simple command
After the myRng object is created, you simply call it via the command
for a uniform random number in the interval (0,1).
The test.cpp file demonstrates how to generate random numbers from other distributions. For example, random numbers from a N(100,sd=16) distribution can be generated by
Calling "myRng" inside an OpenMP parallel region causes OMPRNG to generate random numbers on each thread (i.e. OMPRNG operates in a parallel manner; specifically, OMPRNG instructs RNGStreams to initialize an RNG stream for each thread). Calling "myRng" inside a serial region causes OMPRNG to generate a random number on one processor (i.e. it behaves in a serial manner). Simple.
MC estimates of pi with 100,000,000 updates:
SERIAL: Intel i5 CPU; 1 thread (no hyperthreading)
$ time ./pi
Monte Carlo estimate of pi based on 100000000 iterations is 3.14145
real 0m15.257s
user 0m15.217s
sys 0m0.008s
PARALLEL: Intel i5 CPU; 2 cores, 4 threads (hyperthreading)
$ time ./pi
Monte Carlo estimate of pi based on 100000000 iterations is 3.14148
real 0m7.038s
user 0m24.470s
sys 0m0.008s
There are no restrictions on the use of OMPRNG except that I take no liability for any problems that may arise from its use.
OMPRNG is free software. However, if you use it in a project or publication, please provide proper credit.
Matthew Bognar
Department of Statistics and Actuarial Science
University of Iowa
http://www.stat.uiowa.edu/~mbognar/omprng
matthew-bognar@uiowa.edu