Posts

Showing posts from July 10, 2019

Random number generator on GPU

Pseudo-random number generation on CPU is simple - we need to store previous state and use it to generate the next number. On a GPU, it's need more attention, we need to generate random numbers in each instance independently. That is, we need to keep for each instance a state, randomly initialized on CPU, and then update the state, using corresponding functions. The good explanation and particular implementation of good random generator is discussed here: https://math.stackexchange.com/questions/337782/pseudo-random-number-generation-on-the-gpu#answers-header It's about method explained in NVidia's book "GPU Gems", Chapter 37. Efficient Random Number Generation and Application Using CUDA https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch37.html So, here is my code: //-------------------------------------------------------------------------- //Random generator for GPU //Based on //https://math.stackexchange.com/questions/337782/pse