Can I use vslSkipAheadStream together with an VSL_BRNG_MT19937 generator and vsRngGaussian?
I have written som small test program which creates one original stream and two skip ahead streams and compare the result. The first stream is identically to the original but the second is not-. Should I be able to do this or am I doing something wrong.
int seed = 12345;
int N = 100;
VSLStreamStatePtr original_stream;
float original_buffer[N];
vslNewStream(&original_stream, VSL_BRNG_MT19937, seed);
vsRngGaussian(
VSL_RNG_METHOD_GAUSSIAN_BOXMULLER,
original_stream,
N,
original_buffer,
0,
1.0f);
VSLStreamStatePtr streams[2];
int NS = 50;
float stream_buffer[N];
for (int i = 0;i < 2;i++) {
vslNewStream(&streams[i], VSL_BRNG_MT19937, seed);
vslSkipAheadStream(streams[i], i * NS);
vsRngGaussian(
VSL_RNG_METHOD_GAUSSIAN_BOXMULLER,
streams[i],
NS,
&stream_buffer[i * NS],
0,
1.0f);
}
for (int i = 0; i < N; i++) {
std::cout << i << " - "<< original_buffer[i] << " : "<< stream_buffer[i] << std::endl;
}
We want to ensure that our MC simulation always uses the same global set of random numbers independently of the number of threads we are using.