Skip to content

Commit

Permalink
fix Windows low quality host RNG due to 15bit rand(), fix #31
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Mar 11, 2018
1 parent 521fb85 commit a0d445b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,13 @@ posix: LINKOPT+=-DUSE_POSIX_RAND
fast: CUCCOPT+=-DUSE_XORSHIFT128P_RAND -use_fast_math
log: CUCCOPT+=
debugxor: xor
debugxor: LINKOPT+=$(OMP)
debuglog: CUCCOPT+=
racing: CUCCOPT+=-DTEST_RACING
xoratomic: CUCCOPT+=-DUSE_XORSHIFT128P_RAND -DUSE_ATOMIC -use_fast_math $(CUGENCODE) MCX_TARGET_NAME='"Xorshift128+ Atomic MCX"'
logatomic: CUCCOPT+=-DUSE_ATOMIC -use_fast_math $(CUGENCODE) -DMCX_TARGET_NAME='"LL5 Atomic MCX"'
fermi fermimex fermioct: CUCCOPT+=-DUSE_ATOMIC -use_fast_math
fermi fermimex fermioct: xoro
fermi fermimex fermioct: xor
fermimex fermioct: OUTPUTFLAG:=-output

fermi: LINKOPT+=$(CUOMPLINK) $(OMP)
Expand Down
7 changes: 4 additions & 3 deletions src/mcx_core.cu
Original file line number Diff line number Diff line change
Expand Up @@ -1658,8 +1658,9 @@ void mcx_run_simulation(Config *cfg,GPUInfo *gpu){
param.twin0=cfg->tstart;
param.twin1=cfg->tend;
Pseed=(uint*)malloc(sizeof(RandType)*RAND_BUF_LEN);
for (i=0; i<(int)(((sizeof(RandType)*RAND_BUF_LEN)>>2)); i++)
Pseed[i]=rand();
for (i=0; i<(int)(((sizeof(RandType)*RAND_BUF_LEN)>>2)); i++){
Pseed[i]=((rand() << 16) | (rand() << 1) | (rand() >> 14));
}
CUDA_ASSERT(cudaMalloc((void **) &gPseed, sizeof(RandType)*RAND_BUF_LEN));
CUDA_ASSERT(cudaMemcpy(gPseed, Pseed, sizeof(RandType)*RAND_BUF_LEN, cudaMemcpyHostToDevice));
CUDA_ASSERT(cudaMalloc((void **) &gfield, sizeof(float)*fieldlen));
Expand Down Expand Up @@ -1880,7 +1881,7 @@ void mcx_run_simulation(Config *cfg,GPUInfo *gpu){

if(cfg->seed!=SEED_FROM_FILE){
for (i=0; i<gpu[gpuid].autothread*((int)(sizeof(RandType)*RAND_BUF_LEN)>>2); i++)
Pseed[i]=rand();
Pseed[i]=((rand() << 16) | (rand() << 1) | (rand() >> 14));
CUDA_ASSERT(cudaMemcpy(gPseed, Pseed, sizeof(RandType)*gpu[gpuid].autothread*RAND_BUF_LEN, cudaMemcpyHostToDevice));
}
tic0=GetTimeMillis();
Expand Down

0 comments on commit a0d445b

Please sign in to comment.