Parallel RNG Manager
Manages a parallel number generator for C++ OpenMP applications
Parallel RNG Manager Documentation

Parallel RNG Manager

The ParallelRngManager class simplifies the task of initializing and coordinating random number generation for multiple threads in OpenMP and other multi-threaded programming environments without the need for locks or the possibility of false sharing. A single integer value is used to seed a single random number generator that is partitioned into independent parallel random number generator streams.

Using a single random number generator seed makes deterministic testing and debugging of parallel stochastic algorithms practical. Additionally it is important to use a random number generator specifically designed for parallel use, as it is not in general safe to use independent random seeds for each processor if strong randomness properties and guaranteed a-correlation of the streams are arithmetically important considerations.

More generally, a parallel random number generator (PRNG) provides a set of N random number generator streams for multi-threaded applications, where each stream is produced from a single underlying random number generator with a single global seed. For certain classes of random number generators, a single stream can efficiently be partitioned into N threads without communication overhead. The parallel_rng::ParallelRngManager class functions as an OpenMP-aware manager for the PRNGs from the Tina's Random Number Generator (TRNG) Library.

Features

Documentation

The ParallelRngManager Doxygen documentation can be build with the OPT_DOC CMake option and is also available on online:

Installation

The easiest method is to use the default build script, which can be easily customized. The default build directory is ./_build and the default install directory is ./_install.

$ git clone https://github.com/markjolah/ParallelRngManager.git
$ cd ParallelRngManager
$ ./build.sh

If TRNG is not available on the system, it is important to have CMAKE_INSTALL_PREFIX set to a valid install directory, even if it is just a local directory, as the autotools build is designed to install into the CMAKE_INSTALL_PREFIX and ParallelRngManager is then expecting to find the TRNG library there.

CMake options

The following CMake options control the build.

Dependencies

ParallelRngManager is designed to be portable, but relies on several system development and numerical libraries. Currently Travis CI uses the trusty image to test ParallelRngManager Standard system dependencies

Tina's Random Number Generator (TRNG)

The ParallelRngManager is a lightweight wrapper around the Tina's Random Number Generator (TRNG) library. This rather specialized numerical library is normally not available on most Linux distributions, so for convenience the ParallelRngManager CMake build system will automatically download, configure, build, and install TRNG (libtrng4.so) into the CMAKE_INSTALL_PREFIX path if it is not already present on the build system. This process uses the AddExternalAutotoolsDependency.cmake function from the UncommonCMakeModules dependency.

Other dependencies

ParallelRngManager uses these reusable header-only component libraries via git subrepo

Testing

ParallelRngManager uses googletest for C++ unit testing and integrates with CTest. To build tests, enable the BUILD_TESTING CMake option and possibly also the OPT_INSTALL_TESTING option to install tests along with ParallelRngManager.

Tests can be run with:

> make test