I am a newbi to CUDA and I am struggling to generate random numbers in my kernels.
I know there are different implementations, and, what is more, in the SDK 4.1 there is an example of the Niederreiter Quasirandom Sequence Generator.
I don't know where to start... I am a bit sad and feeling like a dummy...
Could anyone please please make a simple and silly example of using the Niederreiter Quasirandom Sequence Generator (SKD code example)? I would really apreciate it.
For example, creating a vector and filling it with random numbers (each thread filling a vector position).
Thank you in advance.
The quasirandomGenerator sample in the SDK does pretty much what you're asking, it takes a region of memory and fills it with quasirandom numbers.
That said, I think you'd be better off using cuRAND, it's Sobol' instead of Niederreiter but unless you have a specific reason for preferring the later you will find it easier to use. For examples of how to use it you should look in the MonteCarloCURAND set of samples:
- EstimatePiQ shows how to allocate a region on GPU memory and fill it with Sobol' numbers
- EstimatePiInlineQ shows how to generate one number at a time within another kernel
The samples ending in P use pseudo-random generators.