i need random number generation function (e.g ranf()) on each thread
for independent sampling on each thread
and i can’t know how many times the code call RNG.
i mean…
i need simple rng function that works on following code
make a many random number and copy to each thread is impossible in my system.
but many RNG code is just random number generation using gpu.
not a function that works on thread!
you should carefully consider if the approach you described is the only one you can do. the do-while will most probably give you diverging threads, so will the if-clause. also the array b should at least be in shared memory (with the scope of a being exclusive to a single thread); otherwise you’ll get single memory transactions for every single thread.
however: you can easily write your own prng yourself on the gpu if you don’t need extremely long periods. for example you can implement a LCG which will give you good random numbers for little cost.
I’m finishing up a PRNG library for both CPU and GPU computation. I had hoped to have it out in time for Nvision but it’ll probably be in a week or two… documentation takes a while!
The PRNG’s goal is high quality, low register use, and easy threading support.
I’ll post when on the CUDA forums when it’s available.