Can cuRAND replicate random sequences as generated by MKL?

I am currently using MKL to generate random sequences with uniform and gaussian distributions. The idea of switching to cuRAND to improve performance looks promising, but I would need to replicate the exact sequences as generated by MKL.

Has anyone looked into this before?

Thanks!

I can’t say for sure, but you might want to try mrg32k3a or philox4x32.

Thanks for the hint!

I noticed that the mrg32k3a device API exposes the internal state of the generator.

struct curandStateMRG32k3a {

  • unsigned int s1[3];*
  • unsigned int s2[3];*
  • int boxmuller_flag;*
  • int boxmuller_flag_double;*
  • float boxmuller_extra;*
  • double boxmuller_extra_double;*
    };

This would allow to set the initial state externally in order to replicate a given sequence.

Is this feature also available in the host API?

Try starting with the Host API example

Change curandCreateGenerator with CURAND_RNG_PSEUDO_MRG32K3A