Using random numbers with GPUs

2019-03-13 09:48发布

I'm investigating using nvidia GPUs for Monte-Carlo simulations. However, I would like to use the gsl random number generators and also a parallel random number generator such as SPRNG. Does anyone know if this is possible?

Update

I've played about with RNG using GPUs. At present there isn't a nice solution. The Mersenne Twister that comes with the SDK isn't really suitable for (my) Monte-Carlo simulations since it takes an incredibly long time to generate seeds.

The NAG libraries are more promising. You can generate RNs either in batches or in individual threads. However, only a few distributions are currently supported - Uniform, exponential and Normal.

标签: c cuda gpu gsl
7条回答
▲ chillily
2楼-- · 2019-03-13 10:28

My colleagues and I have a preprint, to appear in the SC11 conference that revisits an alternative technique for generating random numbers that is well-suited to GPUs. The idea is that the nth random number is:

x_n = f(n) 

In contrast to the conventional approach where

x_n = f(x_{n-1})

Source code is available, which implements several different generators. offering 2^64 or more streams, each with periods of 2^128 or more. All pass a wide assortment of tests (the TestU01 Crush and BigCrush suites) of both intra-stream and inter-stream statistical independence. The library also includes adapters that allow you to use our generators in a GSL framework.

查看更多
劳资没心,怎么记你
3楼-- · 2019-03-13 10:30

The GSL manual recommends the Mersenne Twister.

The Mersenne Twister authors have a version for Nvidia GPUs. I looked into porting this to the R package gputools but found that I needed excessively large number of draws (millions, I think) before the combination of 'generate of GPU and make available to R' was faster than just drawing in R (using only the CPU).

It really is a computation / communication tradeoff.

查看更多
Lonely孤独者°
4楼-- · 2019-03-13 10:35

Here we use sobol sequences on the GPUs.

查看更多
手持菜刀,她持情操
5楼-- · 2019-03-13 10:40

Massive parallel random generation as you need it for GPUs is a difficult problem. This is an active research topic. You really have to be careful not only to have a good sequential random generator (these you find in the literature) but something that guarantees that they are independent. Pairwise independence is not sufficient for a good Monte Carlo simulation. AFAIK there is no good public domain code available.

查看更多
小情绪 Triste *
6楼-- · 2019-03-13 10:41

Use the Mersenne Twister PRNG, as provided in the CUDA SDK.

查看更多
叛逆
7楼-- · 2019-03-13 10:42

I've just found that NAG provide some RNG routines. These libraries are free for academics.

查看更多
登录 后发表回答