Skip to content

Commit

Permalink
[bug] critical: fix double-multiplication of pattern launched weight, f…
Browse files Browse the repository at this point in the history
…ix #212

this is a critical bug and impact all single non-binary-pattern simulations. the diffuse reflectance is not impacted, photon-sharing based simulations are not impacted; binary pattern simulations are not impacted. the diffuse reflectance ouput was previous fixed in c04bff5
  • Loading branch information
fangq committed Feb 27, 2024
1 parent b7822ac commit 8e03878
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/mcx_core.cu
Original file line number Diff line number Diff line change
Expand Up @@ -2135,9 +2135,9 @@ __global__ void mcx_main_loop(uint media[], OutputType field[], float genergy[],
for (int i = 0; i < gcfg->srcnum; i++) {
if (fabs(ppath[gcfg->w0offset + i]) > 0.f) {
#ifdef USE_DOUBLE
atomicAdd(& field[(idx1dold + tshift * gcfg->dimlen.z)*gcfg->srcnum + i], weight * ppath[gcfg->w0offset + i]);
atomicAdd(& field[(idx1dold + tshift * gcfg->dimlen.z)*gcfg->srcnum + i], (gcfg->srcnum == 1 ? weight : weight * ppath[gcfg->w0offset + i]));
#else
float oldval = atomicadd(& field[(idx1dold + tshift * gcfg->dimlen.z) * gcfg->srcnum + i], weight * ppath[gcfg->w0offset + i]);
float oldval = atomicadd(& field[(idx1dold + tshift * gcfg->dimlen.z) * gcfg->srcnum + i], (gcfg->srcnum == 1 ? weight : weight * ppath[gcfg->w0offset + i]));

if (fabsf(oldval) > MAX_ACCUM && gcfg->outputtype != otRF) {
atomicadd(& field[(idx1dold + tshift * gcfg->dimlen.z)*gcfg->srcnum + i], ((oldval > 0.f) ? -MAX_ACCUM : MAX_ACCUM));
Expand Down

0 comments on commit 8e03878

Please sign in to comment.