Hi! I’m trying 2 days now to generate a simple random number in CUDA.
I have already search this forum and google and don’t understand how to
generate a simple random number. I know there is a SDK example “MersenneTwister”,
but this looks way to overkill for my application. I only want my kernel to generate ONE random number.
Is there any simple method to do this? It would really help me to progress.
This is what i use
z=__umul24(a1,(z&65535))+(z>>16);
w=__umul24(a2,(w&65535))+(w>>16);
return ((z<<16)+w)*2.328306e-10f;
It is a combined MCW generator. See http://school.anhb.uwa.edu.au/personalpage…arsaglia99.html
See Thrust’s monte_carlo example, which uses thrust::default_random_engine and thrust::uniform_real_distribution to produce numbers in [0.0, 1.0).
Thank you very much, Thrust was exact what I was searching for!