diff --git a/src/CUDA/CudaBase.cu b/src/CUDA/CudaBase.cu index 03fa327..b6af691 100644 --- a/src/CUDA/CudaBase.cu +++ b/src/CUDA/CudaBase.cu @@ -41,14 +41,15 @@ CudaBase::~CudaBase() { /* create curandStates */ -int CudaBase::cuda_createCurandStates(int size) { +int CudaBase::cuda_createCurandStates(int size, int seed) { if (defaultRndSet == 1) cuda_deleteCurandStates(); int threads = 128; int blocks = size / threads + 1; - int seed = time(NULL); + if (seed == -1) + seed = time(NULL); //std::cout << "sizeof: " << sizeof(curandState) << std::endl; cudaMalloc(&defaultRndState, sizeof(curandState)*size); diff --git a/src/CUDA/CudaBase.cuh b/src/CUDA/CudaBase.cuh index 325016d..6f3d182 100644 --- a/src/CUDA/CudaBase.cuh +++ b/src/CUDA/CudaBase.cuh @@ -41,7 +41,7 @@ public: * and create a curandState with different seed for each array entry. * Return success or error code */ - int cuda_createCurandStates(int size); + int cuda_createCurandStates(int size, int seed = -1); /** * Delete curandState. diff --git a/src/DKSBase.cpp b/src/DKSBase.cpp index 96e9b19..8ea5f58 100644 --- a/src/DKSBase.cpp +++ b/src/DKSBase.cpp @@ -807,9 +807,9 @@ int DKSBase::callCollimatorPhysicsSortSoA(void *label_ptr, void *localID_ptr, } -int DKSBase::callInitRandoms(int size) { +int DKSBase::callInitRandoms(int size, int seed) { if (apiCuda()) - return CUDA_SAFECALL(cbase->cuda_createCurandStates(size)); + return CUDA_SAFECALL(cbase->cuda_createCurandStates(size, seed)); else if (apiOpenCL()) return OPENCL_SAFECALL(oclbase->ocl_createRndStates(size)); else if (apiOpenMP()) diff --git a/src/DKSBase.h b/src/DKSBase.h index ea8bc39..79e23c8 100644 --- a/src/DKSBase.h +++ b/src/DKSBase.h @@ -1074,7 +1074,7 @@ public: * Init random number states and save for reuse on device. * TODO: opencl and mic implementations. */ - int callInitRandoms(int size); + int callInitRandoms(int size, int seed = -1); /** * Integration code from ParallelTTracker from OPAL.