I’m trying to use the curand library to create random numbers inside an optix program. Running a test program seems to show that curand_init fails when subsequence and offset are not zero.
The program does this (it’s basically just a kernel, despite the slightly different syntax)
I have a couple of questions to make sure I’m looking at the right code…
Are you using the default generator (XORWOW)?
I’m wondering about your use of [launch_index] as an index into your state array, when it looks from the rtPrintf to be a structure?
Are you able to build and run the kernel example from the documentation pages? (It does something very similar to your example with curand_init)
The printf in your sample code doesn’t print a random number, so I’m wondering if you could include more of your program so I can see how the kernel is invoked.
Thanks that helps. The issue is the asynchronous nature of kernel printf. To see all the kernel printf’s in sequence with those from the CPU you can add a cudaThreadSynchronize() after each kernel call. When I did this with your sample code the output looks like:
I tried to use curand in OptiX as well. Since in OptiX there is no dimention control of grid and block, and all generator-algorithmes are closely tied to number of thread and block. I wonder how you manage to initialize states.
thanks in advance.