I'm currently working with ManagedCuda, and want to generate random numbers on the device. However I can't seem to find a simple example how to do this (browsing through objects in the ManagedCuda.CudaRand
namespace and comparing with the C++ equivalent doesn't get me any further).
Actual question: How can I generate random numbers in a kernel when using managedCuda instead of the regular C++ API?
As it seems, you only want to use the device side API of CURAND, you will be then entirely independent of managedCuda: All you need to do in managedCuda is to allocate a large enough chunk of memory to save the current curandStates. You don’t even need a reference to managedCuda's CudaRand.dll.
Then you create an init kernel that calls for each thread
curand_init()
and then in your actual kernel you usecurand_normal()
or any of the other rand-functions. A step-by-step example is given in the curand manual in chapter 3.6.