Skip to content

Commit

Permalink
fix photon sharing normalization and issue fangq#41 for WP/DCS output
Browse files Browse the repository at this point in the history
  • Loading branch information
ShijieYan committed Jan 14, 2019
1 parent ea715e4 commit 9861c28
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/mcx_core.cu
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,13 @@ kernel void mcx_main_loop(uint media[],float field[],float genergy[],uint n_seed
field[idx1d+tshift*gcfg->dimlen.z]+=tmp0*replayweight[(idx*gcfg->threadphoton+min(idx,gcfg->oddphotons-1)+(int)f.ndone)];
#ifdef USE_ATOMIC
}else{
atomicadd(& field[idx1d+tshift*gcfg->dimlen.z], tmp0*replayweight[(idx*gcfg->threadphoton+min(idx,gcfg->oddphotons-1)+(int)f.ndone)]);
float oldval=atomicadd(& field[idx1d+tshift*gcfg->dimlen.z], tmp0*replayweight[(idx*gcfg->threadphoton+min(idx,gcfg->oddphotons-1)+(int)f.ndone)]);
if(oldval>MAX_ACCUM){
if(atomicadd(& field[idx1d+tshift*gcfg->dimlen.z], -oldval)<0.f)
atomicadd(& field[idx1d+tshift*gcfg->dimlen.z], oldval);
else
atomicadd(& field[idx1d+tshift*gcfg->dimlen.z+gcfg->dimlen.w], oldval);
}
GPUDEBUG(("atomic write to [%d] %e, w=%f\n",idx1d,tmp0*replayweight[(idx*gcfg->threadphoton+min(idx,gcfg->oddphotons-1)+(int)f.ndone)],p.w));
}
#endif
Expand Down Expand Up @@ -2067,7 +2073,7 @@ is more than what your have specified (%d), please use the -H option to specify
int j;
for(iter=0;iter<gpu[gpuid].maxgate;iter++)
for(j=0;j<(int)dimlen.z;j++)
mcx_kahanSum(&energyabs[i],&kahanc,cfg->exportfield[iter*dimxyz+(j*cfg->srcnum+i)]*cfg->prop[cfg->vol[j]].mua);
mcx_kahanSum(&energyabs[i],&kahanc,cfg->exportfield[iter*dimxyz+(j*cfg->srcnum+i)]*cfg->prop[(uint)cfg->vol[j] & MED_MASK].mua);
}
}
}
Expand Down

0 comments on commit 9861c28

Please sign in to comment.