Mersenne Twister

Dear all,

I am trying to generate an array of 1000 random numbers.

#include <cuda.h>
#include <cutil_inline.h>

#include “MersenneTwister.h”
#include “MersenneTwister_kernel.cu”

//ceil(a / b)
extern “C” int iDivUp(int a, int b){
return ((a % b) != 0) ? (a / b + 1) : (a / b);
}

//floor(a / b)
extern “C” int iDivDown(int a, int b){
return a / b;
}

//Align a to nearest higher multiple of b
extern “C” int iAlignUp(int a, int b){
return ((a % b) != 0) ? (a - a % b + b) : a;
}

//Align a to nearest lower multiple of b
extern “C” int iAlignDown(int a, int b){
return a - a % b;
}

int main(){
int N = 1000;
const int N_PER_RNG = iDivUp(N, MT_RNG_COUNT);
seedMTGPU(777);

float Rand_d;
cudaMalloc((void **) &Rand_d, N
sizeof(float));

RandomGPU<<<32, 128>>>(Rand_d, N_PER_RNG);
}

However, all the elements of Rand_d are the same. Am I doing something wrong? Thanks for the help.

Did you ever get your problem fixed? I am trying to get the Mersenne Twister to work for me as well, but not having much luck. I would like to hear about your experiences.

Jonathan Scott