From 026eebfa55fc64ecd255331f2bb9a69a6912c920 Mon Sep 17 00:00:00 2001 From: Qianqian Fang Date: Fri, 7 Jun 2024 23:36:58 -0400 Subject: [PATCH] [bug] ensure to clear shared mem buffer regardless of weight, #222 --- src/mcx_core.cu | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/mcx_core.cu b/src/mcx_core.cu index 6c3e1dd7..7df3737b 100644 --- a/src/mcx_core.cu +++ b/src/mcx_core.cu @@ -1096,7 +1096,7 @@ __device__ inline int launchnewphoton(MCXpos* p, MCXdir* v, Stokes* s, MCXtime* } } - if (*mediaid == 0 && *idx1d != OUTSIDE_VOLUME_MIN && *idx1d != OUTSIDE_VOLUME_MAX && gcfg->issaveref) { + if (*mediaid == 0 && *idx1d != OUTSIDE_VOLUME_MIN && *idx1d != OUTSIDE_VOLUME_MAX && gcfg->issaveref && p->w > 0.f) { if (gcfg->issaveref == 1) { int tshift = MIN(gcfg->maxgate - 1, (int)(floorf((f->t - gcfg->twin0) * gcfg->Rtstep))); @@ -1154,13 +1154,19 @@ __device__ inline int launchnewphoton(MCXpos* p, MCXdir* v, Stokes* s, MCXtime* (nuvox->sv.isupper ? nuvox->sv.upper : nuvox->sv.lower) == 0)) && gcfg->issaveref < 2) { savedetphoton(n_det, dpnum, ppath, p, v, s, photonseed, seeddata, isdet); } - - clearpath(ppath, gcfg->partialdata); } #endif } +#ifdef SAVE_DETECTORS + + if (gcfg->savedet) { + clearpath(ppath, gcfg->partialdata); + } + +#endif + /** * If the thread completes all assigned photons, terminate this thread. */