How could we generate random numbers in CUDA C with different seed on each run?

前端 未结 3 614
情深已故
情深已故 2021-02-10 01:16

I am working on a stochastic process and I wanted to generate different series if random numbers in CUDA kernel each time I run the program. This similar to what we does in C++

3条回答
  •  执笔经年
    2021-02-10 01:59

    Using a different seed on each run should be straightforward. The exact method will depend on which generator you are using, but if you're using one of the cuRAND generators then you can cast your time_t from time(NULL) to a 64-bit integer and pass it in to the seed functions.

    If you're calling the generator from your kernel you will need to pass this seed in either as a kernel argument or via a __device__ variable. You can then use an offset to curand_init() or use skip_ahead() to get distinct sub-sequences.

    If you have a specific generator for which this will not work, please post more information.

提交回复
热议问题