 # lines in MersenneTwister Can the MT sample make good random ?

I would like to use the MersenneTwister routine in CUDA1.1 sample code as the random number generator for my MonteCarlo calculation. I added the following “printf” lines for checking the validity of this code;

``````      for(i = 0; i < MT_RNG_COUNT; i++)

for(j = 0; j < N_PER_RNG; j++){

rCPU = h_RandCPU[i * N_PER_RNG + j];

rGPU = h_RandGPU[i + j * MT_RNG_COUNT];

delta = fabs(rCPU - rGPU);

/*-----------------------------------------------------------------------------------*/

printf("%i \t %+10.8e \t %i \t %+10.8e \t %+10.8e\n",

i + j * MT_RNG_COUNT,             rGPU,

i * N_PER_RNG + j,                    rCPU,

delta);

/*----------------------------------------------------------------------------------*/

sum_delta += delta;

sum_ref   += fabs(rCPU);

if(delta >= max_delta) max_delta = delta;

}
``````

This “for” block is from (about) 188 lines of the MersenneTwister.cu.

After generating the (131072=4096*32) random numbers, I put the points on the 3rd column (index of number) vs 2nd column (random number) plane by using gnuplot. I can see a few lines (bias of tone, shade) in the figures. I also draw the numbers on the 1st column (index of random number) vs 2nd column (random number) plane for the cross check. I also find the horizontal bars in a few regions.

I changed the seed or the sample numbers of the random numbers, but this feature is not changed.

Is this result correct for this code ? Or am I wrong ??

#the sample code says “TEST PASSED”, anyway.

If this is correct result, I cannot use this code for my calculation.

MT generates very good random numbers. but I dont know about the SDK. The MT code is freely available on NET. Check out their original paper – Its an ACM paper - “ACM Transactions on Modeling and Computer simulation, Vol 8, No. 1, January 1998”

To use for Monte Carlo - you need to do Box-Mueller transformation on this set of random numbers – so that they become standard normal random numbers.

I know that the MT is one of the food method to generate the random number. Since I have used the MT method with CPU for my projects, I try to use the MT in GPU for my next projects.

My conclusion till now is

1. I am wrong to pick up the random number form the MT program in CUDA.

or

1. The MT program in CUDA sample is not good one. I can generate short length random number by using this sample, but cannot make enough length.

or

1. the other. But the MT method is OK, which I know.