Random Number Generator on CUDA

Hi,

I am a newbie in CUDA and as a part of my project i have to implement an RNG so does anyone know if there is a CUDA implementation of a RNG algorithme, respecting all the main randomly-proprieties??

thanks in advance :wave:

There is a Mersenne Twister implementation in the SDK examples.

Or see my implementation that provides one MT random series across up to 512 threads. The Nvidia implementation creates a separate series for each thread and uses a much smaller period MT to reduce state per thread. I don’t think it is valid to use separate series in the one calculation.

Eric

The implementation in the SDK is using the Dynamic Creator Mersenne Twister
(http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/DC/dc.html).
It generates independent random streams and it is designed for parallel machines or distributed systems.
You can read the paper from the link above, if you want to find out more about the statistical properties of the methods.

For a simple and fast implementation of the GNU rand48 for CUDA, have a look at our MDGPU page.
There, you can download the RNG with source as a stand-alone component.

I use two different RNGs:

  1. Mersenne Twister with different seeds for each task. This is mathematically unsound but looks fine for my application.

  2. a port of the LCG from the SPRNG2.0 library.

I would like to use your implementation of MT for a kernel in which each thread in the grid needs an independent stream of randoms irrespective of whether threads are in the same block or not. Does mt19937 do this?

Do I need to use mt19937g() for this?

Sorry, I am studying the code but everything is not yet clear to me.

Is there an overview document anywhere that gives clues about how best to use mt19937?

Thanks.