0

For debugging purposes, I need to generate the same random sequence in all the threads of a given block using cuda random library, curand.

I tried with zero seed and zero sequence, with marsenne twister and xorwow, but I still get two different sequences if the block has different number of threads.

For example, with curand_init(0, 0, 0, &state) and one thread, I get two numbers: 0.442526 0.809567

with the same initialization code, but two threads, I get: 0.446065 0.730273

Given that I do not really care about the engine used for now, how can I get the same random sequence given the seed parameters and independently from the number of threads in that block?

AkiRoss
  • 11,745
  • 6
  • 59
  • 86
  • 1
    Can you show your code? You're doing something wrong. Do you have individual state per thread? – Robert Crovella May 25 '13 at 01:43
  • Create your own poor random number generator (e. g. rand() { return (state += prime1)%prime2; } I assume this is for simple testing. – chux - Reinstate Monica May 25 '13 at 01:57
  • 2
    In [this answer](http://stackoverflow.com/questions/15247522/cuda-random-number-generation/15252202#15252202) I give a complete code for getting the same random sequence in each thread. – Robert Crovella May 25 '13 at 02:34

0 Answers0