Skip to content

Commit

Permalink
[bug] fix incorrect shared memory initialization, fix #101, fix #103
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Nov 3, 2024
1 parent 22bcdbd commit 6baa839
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions mmclab/example/demo_example_replay.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
cfg.issaveexit = 1; % save detected photon exit position and angles
cfg.issaveseed = 1; % save detected photon seeds to replay later
% cfg.method=0;
cfg.compute='cuda';

newcfg = mmclab(cfg, 'prep'); % preprocessing of the mesh to get the missing fields

Expand Down
7 changes: 4 additions & 3 deletions src/mmc_core.cl
Original file line number Diff line number Diff line change
Expand Up @@ -1455,6 +1455,10 @@ __device__ void onephoton(unsigned int id, __local float* ppath, __constant MCXP
RandType initseed[RAND_BUF_LEN];
#endif

clearpath(ppath, (GPU_PARAM(gcfg, reclen) + (GPU_PARAM(gcfg, srcnum) > 1) * GPU_PARAM(gcfg, srcnum)));
clearpath(energytot, GPU_PARAM(gcfg, srcnum));
clearpath(energyesc, GPU_PARAM(gcfg, srcnum));

r.photonid = id;

#ifdef MCX_SAVE_SEED
Expand Down Expand Up @@ -1734,9 +1738,6 @@ __kernel void mmc_main_loop(const int nphoton, const int ophoton,
gpu_rng_init(t, n_seed, idx);
}

clearpath(sharedmem, get_local_size(0) * ((GPU_PARAM(gcfg, srcnum) << 1) +
(GPU_PARAM(gcfg, reclen) + (GPU_PARAM(gcfg, srcnum) > 1) * GPU_PARAM(gcfg, srcnum))));

/*launch photons*/
for (int i = 0; i < nphoton + (idx < ophoton); i++) {
if (GPU_PARAM(gcfg, seed) == SEED_FROM_FILE)
Expand Down

0 comments on commit 6baa839

Please sign in to comment.