Using CuRand in ManagedCuda

367 views Asked by At

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?

1

There are 1 answers

4
kunzmi On BEST ANSWER

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 use curand_normal() or any of the other rand-functions. A step-by-step example is given in the curand manual in chapter 3.6.