Skip to content

Commit

Permalink
Merge branch 'master' of github.com:fangq/mcxcl
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Jun 12, 2024
2 parents 4609451 + 2b91626 commit 2cd9c9e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
15 changes: 9 additions & 6 deletions src/mcx_core.cl
Original file line number Diff line number Diff line change
Expand Up @@ -960,8 +960,11 @@ int launchnewphoton(float4* p, float4* v, float4* f, short4* flipdir, FLOAT4VEC*
#if defined(MCX_SRC_PLANAR) || defined(MCX_SRC_PATTERN) || defined(MCX_SRC_PATTERN3D) || defined(MCX_SRC_FOURIER) || defined(MCX_SRC_PENCILARRAY) /*a rectangular grid over a plane*/
float rx = rand_uniform01(t);
float ry = rand_uniform01(t);
float rz;

#if defined(MCX_SRC_PATTERN3D)

float rz;

rz = rand_uniform01(t);
p[0] = (float4)(p[0].x + rx * gcfg->srcparam1.x,
p[0].y + ry * gcfg->srcparam1.y,
Expand Down Expand Up @@ -1169,8 +1172,8 @@ int launchnewphoton(float4* p, float4* v, float4* f, short4* flipdir, FLOAT4VEC*
} else { // odd number length, interpolate between neigboring values
ang = fmin(rand_uniform01(t) * (GPU_PARAM(gcfg, nangle) - 1), GPU_PARAM(gcfg, nangle) - 1 - EPS);
sphi = ang - ((int)ang);
cphi = ((1.f - sphi) * (((__local float*)(sharedmem))[((int)ang >= GPU_PARAM(gcfg, nangle) - 1 ? GPU_PARAM(gcfg, nangle) - 1 : (int)(ang)) + GPU_PARAM(gcfg, nphaselen)]) +
sphi * (((__local float*)(sharedmem))[((int)ang + 1 >= GPU_PARAM(gcfg, nangle) - 1 ? GPU_PARAM(gcfg, nangle) - 1 : (int)(ang) + 1) + GPU_PARAM(gcfg, nphaselen)]));
cphi = ((1.f - sphi) * (((__local float*)(sharedmem))[((uint)ang >= GPU_PARAM(gcfg, nangle) - 1 ? GPU_PARAM(gcfg, nangle) - 1 : (int)(ang)) + GPU_PARAM(gcfg, nphaselen)]) +
sphi * (((__local float*)(sharedmem))[((uint)ang + 1 >= GPU_PARAM(gcfg, nangle) - 1 ? GPU_PARAM(gcfg, nangle) - 1 : (int)(ang) + 1) + GPU_PARAM(gcfg, nphaselen)]));
}

cphi *= ONE_PI; // next zenith angle computed based on angleinvcdf
Expand Down Expand Up @@ -1351,7 +1354,7 @@ __kernel void mcx_main_loop(__global const uint* media,
barrier(CLK_LOCAL_MEM_FENCE);
}

if (idx >= gcfg->threadphoton * (get_local_size(0) * get_num_groups(0)) + gcfg->oddphoton) {
if ((uint)idx >= gcfg->threadphoton * (get_local_size(0) * get_num_groups(0)) + gcfg->oddphoton) {
return;
}

Expand Down Expand Up @@ -1424,8 +1427,8 @@ __kernel void mcx_main_loop(__global const uint* media,
if (GPU_PARAM(gcfg, nphase) > 2) { // after padding the left/right ends, nphase must be 3 or more
tmp0 = rand_uniform01(t) * (GPU_PARAM(gcfg, nphase) - 1);
theta = tmp0 - ((int)tmp0);
tmp0 = (1.f - theta) * ((__local float*)(sharedmem))[(int)tmp0 >= GPU_PARAM(gcfg, nphase) ? GPU_PARAM(gcfg, nphase) - 1 : (int)(tmp0) ] +
theta * ((__local float*)(sharedmem))[(int)tmp0 + 1 >= GPU_PARAM(gcfg, nphase) ? GPU_PARAM(gcfg, nphase) - 1 : (int)(tmp0) + 1];
tmp0 = (1.f - theta) * ((__local float*)(sharedmem))[(uint)tmp0 >= GPU_PARAM(gcfg, nphase) ? GPU_PARAM(gcfg, nphase) - 1 : (int)(tmp0) ] +
theta * ((__local float*)(sharedmem))[(uint)tmp0 + 1 >= GPU_PARAM(gcfg, nphase) ? GPU_PARAM(gcfg, nphase) - 1 : (int)(tmp0) + 1];
theta = acos(tmp0);
stheta = MCX_MATHFUN(sin)(theta);
ctheta = tmp0;
Expand Down
2 changes: 1 addition & 1 deletion src/mcx_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -3191,7 +3191,7 @@ void mcx_loadseedjdat(char* filename, Config* cfg) {
uint dims[3] = {1, 1, 1};
float* ppath = NULL;
char* type;
History his = {0};
History his = {{0}};

cJSON* vsize = cJSON_GetObjectItem(seed, "_ArraySize_");

Expand Down
2 changes: 1 addition & 1 deletion src/mcx_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ typedef struct MCXConfig {
float4* detpos; /**<detector positions and radius, overwrite detradius*/

unsigned int maxgate; /**<simultaneous recording gates*/
unsigned int respin; /**<number of repeatitions (if positive), or number of divisions (if negative)*/
int respin; /**<number of repeatitions (if positive), or number of divisions (if negative)*/
unsigned int printnum; /**<number of printed threads (for debugging)*/
int gpuid; /**<the ID of the GPU to use, starting from 1, 0 for auto*/

Expand Down
4 changes: 2 additions & 2 deletions test/testmcx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ if [ -z "$temp" ]; then echo "fail to save photon seeds"; fail=$((fail+1)); else

echo "test photon replay flag -E ... "
rm -rf replaytest.*
temp=`("$MCX" --bench cube60 -s replaytest -q 1 -S 0 $PARAM && "$MCX" --bench cube60 -E replaytest_detp.jdat -S 0 $PARAM) | sed 's/\x1b\[[0-9;]*m//g' | grep -o -E '(simulated|detected)\s+[0-9.]+ photons' | tail -2 | sed -e 's/^[a-z ]*//g' | sort | uniq -c | grep '^\s*2\s*\d*'`
temp=`("$MCX" --bench cube60 -s replaytest -q 1 -S 0 $PARAM && "$MCX" --bench cube60 -E replaytest_detp.jdat -S 0 $PARAM) | sed $'s/\x1b\[[0-9;]*m//g' | grep -o -E '(simulated|detected)\s+[0-9.]+ photons' | tail -2 | sed -e 's/^[a-z ]*//g' | sort | uniq -c | grep '^\s*2\s*\d*'`
if [ -z "$temp" ]; then echo "fail to run photon replay -E"; fail=$((fail+1)); else echo "ok"; fi

echo "test photon replay ... "
rm -rf replaytest.*
temp=`("$MCX" --bench cube60 -s replaytest -q 1 -S 0 $PARAM && "$MCX" --bench cube60 -E replaytest_detp.jdat -S 0 $PARAM) | sed 's/\x1b\[[0-9;]*m//g' | grep -o -E 'absorbed:.*3[0-8]\.[0-9]+%'`
temp=`("$MCX" --bench cube60 -s replaytest -q 1 -S 0 $PARAM && "$MCX" --bench cube60 -E replaytest_detp.jdat -S 0 $PARAM) | sed $'s/\x1b\[[0-9;]*m//g' | grep -o -E 'absorbed:.*3[0-8]\.[0-9]+%'`
if [ -z "$temp" ]; then echo "fail to run photon replay"; fail=$((fail+1)); else echo "ok"; fi

echo "test heterogeneous domain ... "
Expand Down

0 comments on commit 2cd9c9e

Please sign in to comment.