Skip to content

Commit 485b1ea

Browse files
committed
clear warnings for gcc 7
1 parent b7c1982 commit 485b1ea

File tree

3 files changed

+42
-41
lines changed

3 files changed

+42
-41
lines changed

src/mcx_core.cu

+14-14
Original file line numberDiff line numberDiff line change
@@ -1579,12 +1579,12 @@ int mcx_list_gpu(Config *cfg, GPUInfo **info){
15791579

15801580
CUDA_ASSERT(cudaGetDeviceCount(&deviceCount));
15811581
if (deviceCount == 0){
1582-
MCX_FPRINTF(stderr,S_RED"ERROR: No CUDA-capable GPU device found\n"S_RESET);
1582+
MCX_FPRINTF(stderr,S_RED "ERROR: No CUDA-capable GPU device found\n" S_RESET);
15831583
return 0;
15841584
}
15851585
*info=(GPUInfo *)calloc(deviceCount,sizeof(GPUInfo));
15861586
if (cfg->gpuid && cfg->gpuid > deviceCount){
1587-
MCX_FPRINTF(stderr,S_RED"ERROR: Specified GPU ID is out of range\n"S_RESET);
1587+
MCX_FPRINTF(stderr,S_RED "ERROR: Specified GPU ID is out of range\n" S_RESET);
15881588
return 0;
15891589
}
15901590
// scan from the first device
@@ -1618,7 +1618,7 @@ int mcx_list_gpu(Config *cfg, GPUInfo **info){
16181618

16191619
if (strncmp(dp.name, "Device Emulation", 16)) {
16201620
if(cfg->isgpuinfo){
1621-
MCX_FPRINTF(stdout,S_BLUE"============================= GPU Infomation ================================\n"S_RESET);
1621+
MCX_FPRINTF(stdout,S_BLUE"============================= GPU Infomation ================================\n" S_RESET);
16221622
MCX_FPRINTF(stdout,"Device %d of %d:\t\t%s\n",(*info)[dev].id,(*info)[dev].devcount,(*info)[dev].name);
16231623
MCX_FPRINTF(stdout,"Compute Capability:\t%u.%u\n",(*info)[dev].major,(*info)[dev].minor);
16241624
MCX_FPRINTF(stdout,"Global Memory:\t\t%u B\nConstant Memory:\t%u B\n"
@@ -1835,7 +1835,7 @@ void mcx_run_simulation(Config *cfg,GPUInfo *gpu){
18351835
totalgates=(int)((cfg->tend-cfg->tstart)/cfg->tstep+0.5);
18361836
#pragma omp master
18371837
if(totalgates>gpu[gpuid].maxgate && cfg->isnormalized){
1838-
MCX_FPRINTF(stderr,S_RED"WARNING: GPU memory can not hold all time gates, disabling normalization to allow multiple runs\n"S_RESET);
1838+
MCX_FPRINTF(stderr,S_RED "WARNING: GPU memory can not hold all time gates, disabling normalization to allow multiple runs\n" S_RESET);
18391839
cfg->isnormalized=0;
18401840
}
18411841
#pragma omp barrier
@@ -1954,7 +1954,7 @@ void mcx_run_simulation(Config *cfg,GPUInfo *gpu){
19541954
#ifndef SAVE_DETECTORS
19551955
#pragma omp master
19561956
if(cfg->issavedet){
1957-
MCX_FPRINTF(stderr,S_RED"WARNING: this MCX binary can not save partial path, please use mcx_det or mcx_det_cached\n"S_RESET);
1957+
MCX_FPRINTF(stderr,S_RED "WARNING: this MCX binary can not save partial path, please use mcx_det or mcx_det_cached\n" S_RESET);
19581958
cfg->issavedet=0;
19591959
}
19601960
#pragma omp barrier
@@ -2052,7 +2052,7 @@ void mcx_run_simulation(Config *cfg,GPUInfo *gpu){
20522052

20532053
CUDA_ASSERT(cudaMemcpyToSymbol(gcfg, &param, sizeof(MCXParam), 0, cudaMemcpyHostToDevice));
20542054

2055-
MCX_FPRINTF(cfg->flog,S_CYAN"launching MCX simulation for time window [%.2ens %.2ens] ...\n"S_RESET
2055+
MCX_FPRINTF(cfg->flog,S_CYAN"launching MCX simulation for time window [%.2ens %.2ens] ...\n" S_RESET
20562056
,param.twin0*1e9,param.twin1*1e9);
20572057

20582058
//total number of repetition for the simulations, results will be accumulated to field
@@ -2137,8 +2137,8 @@ void mcx_run_simulation(Config *cfg,GPUInfo *gpu){
21372137
{
21382138
if(debugrec>0){
21392139
if(debugrec>cfg->maxdetphoton){
2140-
MCX_FPRINTF(cfg->flog,S_RED"WARNING: the saved trajectory positions (%d) \
2141-
are more than what your have specified (%d), please use the --maxjumpdebug option to specify a greater number\n"S_RESET
2140+
MCX_FPRINTF(cfg->flog,S_RED "WARNING: the saved trajectory positions (%d) \
2141+
are more than what your have specified (%d), please use the --maxjumpdebug option to specify a greater number\n" S_RESET
21422142
,debugrec,cfg->maxjumpdebug);
21432143
}else{
21442144
MCX_FPRINTF(cfg->flog,"saved %ud trajectory positions, total: %d\t",debugrec,cfg->maxjumpdebug+debugrec);
@@ -2157,11 +2157,11 @@ are more than what your have specified (%d), please use the --maxjumpdebug optio
21572157
if(cfg->issaveseed)
21582158
CUDA_ASSERT(cudaMemcpy(seeddata, gseeddata,sizeof(RandType)*cfg->maxdetphoton*RAND_BUF_LEN,cudaMemcpyDeviceToHost));
21592159
if(detected>cfg->maxdetphoton){
2160-
MCX_FPRINTF(cfg->flog,S_RED"WARNING: the detected photon (%d) \
2161-
is more than what your have specified (%d), please use the -H option to specify a greater number\t"S_RESET
2160+
MCX_FPRINTF(cfg->flog,S_RED "WARNING: the detected photon (%d) \
2161+
is more than what your have specified (%d), please use the -H option to specify a greater number\t" S_RESET
21622162
,detected,cfg->maxdetphoton);
21632163
}else{
2164-
MCX_FPRINTF(cfg->flog,"detected "S_BOLD""S_BLUE"%d photons"S_RESET", total: "S_BOLD""S_BLUE"%ld"S_RESET"\t",detected,cfg->detectedcount+detected);
2164+
MCX_FPRINTF(cfg->flog,"detected " S_BOLD "" S_BLUE "%d photons" S_RESET", total: " S_BOLD "" S_BLUE "%ld" S_RESET"\t",detected,cfg->detectedcount+detected);
21652165
}
21662166
#pragma omp atomic
21672167
cfg->his.detected+=detected;
@@ -2358,16 +2358,16 @@ is more than what your have specified (%d), please use the -H option to specify
23582358
Ppos[i].x,Ppos[i].y,Ppos[i].z,Plen[i].y,Plen[i].x,(float)Pseed[i]);
23592359
}
23602360
// total energy here equals total simulated photons+unfinished photons for all threads
2361-
MCX_FPRINTF(cfg->flog,"simulated %ld photons (%ld) with %d threads (repeat x%d)\nMCX simulation speed: "S_BOLD""S_BLUE"%.2f photon/ms\n"S_RESET,
2361+
MCX_FPRINTF(cfg->flog,"simulated %ld photons (%ld) with %d threads (repeat x%d)\nMCX simulation speed: " S_BOLD "" S_BLUE "%.2f photon/ms\n" S_RESET,
23622362
(long int)cfg->nphoton*((cfg->respin>1) ? (cfg->respin) : 1),(long int)cfg->nphoton*((cfg->respin>1) ? (cfg->respin) : 1),
23632363
gpu[gpuid].autothread,ABS(cfg->respin),(double)cfg->nphoton*((cfg->respin>1) ? (cfg->respin) : 1)/max(1,cfg->runtime)); fflush(cfg->flog);
23642364
if(cfg->srctype==MCX_SRC_PATTERN && cfg->srcnum>1){
23652365
for(i=0;i<(int)cfg->srcnum;i++){
2366-
MCX_FPRINTF(cfg->flog,"source #%d total simulated energy: %.2f\tabsorbed: "S_BOLD""S_BLUE"%5.5f%%"S_RESET"\n(loss due to initial specular reflection is excluded in the total)\n",
2366+
MCX_FPRINTF(cfg->flog,"source #%d total simulated energy: %.2f\tabsorbed: " S_BOLD "" S_BLUE "%5.5f%%" S_RESET"\n(loss due to initial specular reflection is excluded in the total)\n",
23672367
i+1,energytot[i],energyabs[i]/energytot[i]*100.f);fflush(cfg->flog);
23682368
}
23692369
}else{
2370-
MCX_FPRINTF(cfg->flog,"total simulated energy: %.2f\tabsorbed: "S_BOLD""S_BLUE"%5.5f%%"S_RESET"\n(loss due to initial specular reflection is excluded in the total)\n",
2370+
MCX_FPRINTF(cfg->flog,"total simulated energy: %.2f\tabsorbed: " S_BOLD "" S_BLUE "%5.5f%%" S_RESET"\n(loss due to initial specular reflection is excluded in the total)\n",
23712371
cfg->energytot,(cfg->energytot-cfg->energyesc)/cfg->energytot*100.f);fflush(cfg->flog);
23722372
fflush(cfg->flog);
23732373
}

src/mcx_utils.c

+27-27
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ void mcx_clearcfg(Config *cfg){
348348

349349
void mcx_savenii(float *dat, size_t len, char* name, int type32bit, int outputformatid, Config *cfg){
350350
FILE *fp;
351-
char fname[MAX_PATH_LENGTH]={'\0'};
351+
char fname[MAX_FULL_PATH]={'\0'};
352352
nifti_1_header hdr;
353353
nifti1_extender pad={{0,0,0,0}};
354354
float *logval=dat;
@@ -434,8 +434,8 @@ void mcx_savenii(float *dat, size_t len, char* name, int type32bit, int outputfo
434434

435435
void mcx_savedata(float *dat, size_t len, Config *cfg){
436436
FILE *fp;
437-
char name[MAX_PATH_LENGTH];
438-
char fname[MAX_PATH_LENGTH];
437+
char name[MAX_FULL_PATH];
438+
char fname[MAX_FULL_PATH];
439439
unsigned int glformat=GL_RGBA32F;
440440

441441
if(cfg->rootpath[0])
@@ -473,7 +473,7 @@ void mcx_savedata(float *dat, size_t len, Config *cfg){
473473

474474
void mcx_savedetphoton(float *ppath, void *seeds, int count, int doappend, Config *cfg){
475475
FILE *fp;
476-
char fhistory[MAX_PATH_LENGTH], filetag;
476+
char fhistory[MAX_FULL_PATH], filetag;
477477
filetag=((cfg->his.detected==0 && cfg->his.savedphoton) ? 't' : 'h');
478478
if(cfg->rootpath[0])
479479
sprintf(fhistory,"%s%c%s.mc%c",cfg->rootpath,pathsep,cfg->session,filetag);
@@ -600,11 +600,11 @@ void mcx_error(const int id,const char *msg,const char *file,const int linenum){
600600
#ifdef MCX_CONTAINER
601601
mcx_throw_exception(id,msg,file,linenum);
602602
#else
603-
MCX_FPRINTF(stdout,S_RED"\nMCX ERROR(%d):%s in unit %s:%d\n"S_RESET,id,msg,file,linenum);
603+
MCX_FPRINTF(stdout,S_RED "\nMCX ERROR(%d):%s in unit %s:%d\n" S_RESET,id,msg,file,linenum);
604604
if(id==-CUDA_ERROR_LAUNCH_FAILED){
605-
MCX_FPRINTF(stdout,S_RED"MCX is terminated by your graphics driver. If you use windows, \n\
605+
MCX_FPRINTF(stdout,S_RED "MCX is terminated by your graphics driver. If you use windows, \n\
606606
please modify TdrDelay value in the registry. Please checkout FAQ #1 for more details:\n\
607-
URL: http://mcx.space/wiki/index.cgi?Doc/FAQ\n"S_RESET);
607+
URL: http://mcx.space/wiki/index.cgi?Doc/FAQ\n" S_RESET);
608608
}
609609
exit(id);
610610
#endif
@@ -780,7 +780,7 @@ void mcx_prepdomain(char *filename, Config *cfg){
780780
if(cfg->seed==SEED_FROM_FILE && cfg->seedfile[0]){
781781
if(cfg->respin>1 || cfg->respin<0){
782782
cfg->respin=1;
783-
fprintf(stderr,S_RED"WARNING: respin is disabled in the replay mode\n"S_RESET);
783+
fprintf(stderr,S_RED "WARNING: respin is disabled in the replay mode\n" S_RESET);
784784
}
785785
mcx_loadseedfile(cfg);
786786
}
@@ -847,7 +847,7 @@ void mcx_loadconfig(FILE *in, Config *cfg){
847847
uint i,gates,itmp;
848848
size_t count;
849849
float dtmp;
850-
char filename[MAX_PATH_LENGTH]={'\0'}, comment[MAX_PATH_LENGTH],strtypestr[MAX_SESSION_LENGTH]={'\0'},*comm;
850+
char filename[MAX_FULL_PATH]={'\0'}, comment[MAX_FULL_PATH],strtypestr[MAX_FULL_PATH]={'\0'},*comm;
851851

852852
if(in==stdin)
853853
fprintf(stdout,"Please specify the total number of photons: [1000000]\n\t");
@@ -1074,7 +1074,7 @@ void mcx_loadconfig(FILE *in, Config *cfg){
10741074
int mcx_loadjson(cJSON *root, Config *cfg){
10751075
int i;
10761076
cJSON *Domain, *Optode, *Forward, *Session, *Shapes, *tmp, *subitem;
1077-
char filename[MAX_PATH_LENGTH]={'\0'};
1077+
char filename[MAX_FULL_PATH]={'\0'};
10781078
Domain = cJSON_GetObjectItem(root,"Domain");
10791079
Optode = cJSON_GetObjectItem(root,"Optode");
10801080
Session = cJSON_GetObjectItem(root,"Session");
@@ -1733,7 +1733,7 @@ void mcx_maskdet(Config *cfg){
17331733
}
17341734
}
17351735
if(cfg->issavedet && count==0)
1736-
MCX_FPRINTF(stderr,S_RED"WARNING: detector %d is not located on an interface, please check coordinates.\n"S_RESET,d+1);
1736+
MCX_FPRINTF(stderr,S_RED "WARNING: detector %d is not located on an interface, please check coordinates.\n" S_RESET,d+1);
17371737
}
17381738

17391739
free(padvol);
@@ -1752,7 +1752,7 @@ void mcx_maskdet(Config *cfg){
17521752
*/
17531753

17541754
void mcx_dumpmask(Config *cfg){
1755-
char fname[MAX_PATH_LENGTH];
1755+
char fname[MAX_FULL_PATH];
17561756
if(cfg->rootpath[0])
17571757
sprintf(fname,"%s%c%s_vol",cfg->rootpath,pathsep,cfg->session);
17581758
else
@@ -1799,7 +1799,7 @@ void mcx_progressbar(float percent, Config *cfg){
17991799
for(j=0;j<percentage;j++) MCX_FPRINTF(stdout,"=");
18001800
MCX_FPRINTF(stdout,(percentage<colwidth-18) ? ">" : "=");
18011801
for(j=percentage;j<colwidth-18;j++) MCX_FPRINTF(stdout," ");
1802-
MCX_FPRINTF(stdout,"] %3d%%"S_RESET,(int)(percent*100));
1802+
MCX_FPRINTF(stdout,"] %3d%%" S_RESET,(int)(percent*100));
18031803
#ifdef MCX_CONTAINER
18041804
mcx_matlab_flush();
18051805
#else
@@ -2296,7 +2296,7 @@ void mcx_printheader(Config *cfg){
22962296
# The MCX Project is funded by the NIH/NIGMS under grant R01-GM114365 #\n\
22972297
###############################################################################\n\
22982298
$Rev:: $2019.4 $Date:: $ by $Author:: $\n\
2299-
###############################################################################\n"S_RESET);
2299+
###############################################################################\n" S_RESET);
23002300
}
23012301

23022302
/**
@@ -2312,10 +2312,10 @@ void mcx_usage(Config *cfg,char *exename){
23122312
usage: %s <param1> <param2> ...\n\
23132313
where possible parameters include (the first value in [*|*] is the default)\n\
23142314
\n"S_BOLD S_CYAN"\
2315-
== Required option ==\n"S_RESET"\
2315+
== Required option ==\n" S_RESET"\
23162316
-f config (--input) read an input file in .json or .inp format\n\
23172317
\n"S_BOLD S_CYAN"\
2318-
== MC options ==\n"S_RESET"\
2318+
== MC options ==\n" S_RESET"\
23192319
-n [0|int] (--photon) total photon number (exponential form accepted)\n\
23202320
max accepted value:9.2234e+18 on 64bit systems\n\
23212321
-r [1|+/-int] (--repeat) if positive, repeat by r times,total= #photon*r\n\
@@ -2350,7 +2350,7 @@ where possible parameters include (the first value in [*|*] is the default)\n\
23502350
-e [0.|float] (--minenergy) minimum energy level to terminate a photon\n\
23512351
-g [1|int] (--gategroup) number of time gates per run\n\
23522352
\n"S_BOLD S_CYAN"\
2353-
== GPU options ==\n"S_RESET"\
2353+
== GPU options ==\n" S_RESET"\
23542354
-L (--listgpu) print GPU information only\n\
23552355
-t [16384|int](--thread) total thread number\n\
23562356
-T [64|int] (--blocksize) thread number per block\n\
@@ -2361,7 +2361,7 @@ where possible parameters include (the first value in [*|*] is the default)\n\
23612361
-W '50,30,20' (--workload) workload for active devices; normalized by sum\n\
23622362
-I (--printgpu) print GPU information and run program\n\
23632363
\n"S_BOLD S_CYAN"\
2364-
== Input options ==\n"S_RESET"\
2364+
== Input options ==\n" S_RESET"\
23652365
-P '{...}' (--shapes) a JSON string for additional shapes in the grid\n\
23662366
-K [1|int|str](--mediabyte) volume data format, use either a number or a str\n\
23672367
1 or byte: 0-128 tissue labels\n\
@@ -2374,7 +2374,7 @@ where possible parameters include (the first value in [*|*] is the default)\n\
23742374
104 or muamus_short: 2x short gray-levels for mua/s\n\
23752375
-a [0|1] (--array) 1 for C array (row-major); 0 for Matlab array\n\
23762376
\n"S_BOLD S_CYAN"\
2377-
== Output options ==\n"S_RESET"\
2377+
== Output options ==\n" S_RESET"\
23782378
-s sessionid (--session) a string to label all output file names\n\
23792379
-O [X|XFEJPM] (--outputtype) X - output flux, F - fluence, E - energy deposit\n\
23802380
/case insensitive/ J - Jacobian (replay mode), P - scattering, \n\
@@ -2409,21 +2409,21 @@ where possible parameters include (the first value in [*|*] is the default)\n\
24092409
hdr - Analyze 7.5 hdr/img format\n\
24102410
tx3 - GL texture data for rendering (GL_RGBA32F)\n\
24112411
\n"S_BOLD S_CYAN"\
2412-
== User IO options ==\n"S_RESET"\
2412+
== User IO options ==\n" S_RESET"\
24132413
-h (--help) print this message\n\
24142414
-v (--version) print MCX revision number\n\
24152415
-l (--log) print messages to a log file instead\n\
24162416
-i (--interactive) interactive mode\n\
24172417
\n"S_BOLD S_CYAN"\
2418-
== Debug options ==\n"S_RESET"\
2418+
== Debug options ==\n" S_RESET"\
24192419
-D [0|int] (--debug) print debug information (you can use an integer\n\
24202420
or or a string by combining the following flags)\n\
24212421
-D [''|RMP] 1 R debug RNG\n\
24222422
/case insensitive/ 2 M store photon trajectory info\n\
24232423
4 P print progress bar\n\
24242424
combine multiple items by using a string, or add selected numbers together\n\
24252425
\n"S_BOLD S_CYAN"\
2426-
== Additional options ==\n"S_RESET"\
2426+
== Additional options ==\n" S_RESET"\
24272427
--root [''|string] full path to the folder storing the input files\n\
24282428
--gscatter [1e9|int] after a photon completes the specified number of\n\
24292429
scattering events, mcx then ignores anisotropy g\n\
@@ -2437,14 +2437,14 @@ where possible parameters include (the first value in [*|*] is the default)\n\
24372437
stored (default: 1e7)\n\
24382438
--faststep [0|1] 1-use fast 1mm stepping, [0]-precise ray-tracing\n\
24392439
\n"S_BOLD S_CYAN"\
2440-
== Example ==\n"S_RESET"\
2440+
== Example ==\n" S_RESET"\
24412441
example: (autopilot mode)\n"S_GREEN"\
2442-
%s -A 1 -n 1e7 -f input.inp -G 1 -D P\n"S_RESET"\
2442+
%s -A 1 -n 1e7 -f input.inp -G 1 -D P\n" S_RESET"\
24432443
or (manual mode)\n"S_GREEN"\
2444-
%s -t 16384 -T 64 -n 1e7 -f input.inp -s test -r 2 -g 10 -d 1 -w dpx -b 1 -G 1\n"S_RESET"\
2444+
%s -t 16384 -T 64 -n 1e7 -f input.inp -s test -r 2 -g 10 -d 1 -w dpx -b 1 -G 1\n" S_RESET"\
24452445
or (use multiple devices - 1st,2nd and 4th GPUs - together with equal load)\n"S_GREEN"\
2446-
%s -A -n 1e7 -f input.inp -G 1101 -W 10,10,10\n"S_RESET"\
2446+
%s -A -n 1e7 -f input.inp -G 1101 -W 10,10,10\n" S_RESET"\
24472447
or (use inline domain definition)\n"S_GREEN"\
2448-
%s -f input.json -P '{\"Shapes\":[{\"ZLayers\":[[1,10,1],[11,30,2],[31,60,3]]}]}'"S_RESET"\n",
2448+
%s -f input.json -P '{\"Shapes\":[{\"ZLayers\":[[1,10,1],[11,30,2],[31,60,3]]}]}'" S_RESET"\n",
24492449
exename,exename,exename,exename,exename);
24502450
}

src/mcx_utils.h

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#define EPS FLT_EPSILON /**< round-off limit */
4141
#define VERY_BIG (1.f/FLT_EPSILON) /**< a big number */
4242

43+
#define MAX_FULL_PATH 2048 /**< max characters in a full file name string */
4344
#define MAX_PATH_LENGTH 1024 /**< max characters in a full file name string */
4445
#define MAX_SESSION_LENGTH 256 /**< max session name length */
4546
#define MAX_DEVICE 256 /**< max number of GPUs to be used */

0 commit comments

Comments
 (0)