RNG on a GPU

  1. What is current best practice for creating, and/or using, random numbers on a GPU?

  2. How/where are random numbers generated when using openACC?



I should have added to the earlier posting that my question is in the context of pgfortran!



Hi Malcom,

I’ve actually been working on this. The current state is that users need to pre-compute an array of random numbers (either on the host on the GPU vi cuRand), and then use this array in the compute region.

However, I have a prototype for the C “rand” function that can be called from an OpenACC compute region (I haven’t prototyped Fortran’s RANDOM_SEED as of yet). The goal is to eventually have the compiler recognize “rand” and “RANDOM_SEED” then automatically add the device RNG calls (one to initialize each thread’s seed before the compute region as well as the call to “rand”). However, there are several challenges left before the compiler can do this and I don’t have a timeline when it will be available.

Given that it is a prototype, I’d rather not post it here. It has not been well tested and I have not analyzed the strength of the random numbers. However if can accept these caveats, send a note to PGI Customer Service (trs@pgroup.com), I’ll have Dave send it to you.

  • Mat

Thanks Mat and Dave.

I was hoping you were further along on the project.

Maybe I can/will find a cluster and use my existing serial code with MPI!