rand function in CUDA


I want to generate a matrix using the function rand(or a similar function).

Is there a way to generate the matrix using the GPU or I have to generate the matrix using the CPU and copy this to the GPU?


There are several RNGs for CUDA:

  1. Mersenne Twister in the SDK
  2. rand48 (http://www.amolf.nl/~vanmeel/mdgpu/download2.html)
  3. A couple more in GPU Gem3

One of the student projects I advised for last semester’s ECE498 class at UIUC implemented a few more (xorshift, and a couple others). The presentations are on the web site still, the source code may be as well, but I’m not certain:



John Stone

Thanks a lot to both of you