Skip to content

Commit

Permalink
add optlevel, update main reference
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Jan 29, 2018
1 parent a519ec0 commit d7a1a2f
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 98 deletions.
7 changes: 6 additions & 1 deletion README.txt
Expand Up @@ -313,7 +313,12 @@ all memory transaction from GPU to CPU.
---------------------------------------------------------------------------
VI. Reference

[1] Qianqian Fang and David A. Boas, "Monte Carlo Simulation of Photon \

[1] Leiming Yu, Fanny Nina-Paravecino, David Kaeli, and Qianqian Fang,
"Scalable and massively parallel Monte Carlo photon transport simulations \
for heterogeneous computing platforms," J. Biomed. Optics, 23(1), 010504 (2018) .

[2] Qianqian Fang and David A. Boas, "Monte Carlo Simulation of Photon \
Migration in 3D Turbid Media Accelerated by Graphics Processing Units,"
Optics Express, vol. 17, issue 22, pp. 20178-20190 (2009).

Expand Down
30 changes: 14 additions & 16 deletions src/mcx_core.cl
@@ -1,19 +1,17 @@
////////////////////////////////////////////////////////////////////////////////
//
// Monte Carlo eXtreme (MCX) - GPU accelerated Monte Carlo 3D photon migration
// -- OpenCL edition
// Author: Qianqian Fang <q.fang at neu.edu>
//
// Reference (Fang2009):
// Qianqian Fang and David A. Boas, "Monte Carlo Simulation of Photon
// Migration in 3D Turbid Media Accelerated by Graphics Processing
// Units," Optics Express, vol. 17, issue 22, pp. 20178-20190 (2009)
//
// mcx_core.cl: OpenCL kernels
//
// Unpublished work, see LICENSE.txt for details
//
////////////////////////////////////////////////////////////////////////////////
/***************************************************************************//**
** \mainpage Monte Carlo eXtreme - GPU accelerated Monte Carlo Photon Migration \
** -- OpenCL edition
** \author Qianqian Fang <q.fang at neu.edu>
** \copyright Qianqian Fang, 2009-2018
**
** \section sref Reference:
** \li \c (\b Yu2018) Leiming Yu, Fanny Nina-Paravecino, David Kaeli, and Qianqian Fang,
** "Scalable and massively parallel Monte Carlo photon transport simulations
** for heterogeneous computing platforms," J. Biomed. Optics, 23(1), 010504 (2018)
**
** \section slicense License
** GPL v3, see LICENSE.txt for details
*******************************************************************************/

#ifdef MCX_SAVE_DETECTORS
#pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics : enable
Expand Down
31 changes: 17 additions & 14 deletions src/mcx_host.cpp
@@ -1,18 +1,16 @@
/*******************************************************************************
**
** Monte Carlo eXtreme (MCX) - GPU accelerated Monte Carlo 3D photon migration
/***************************************************************************//**
** \mainpage Monte Carlo eXtreme - GPU accelerated Monte Carlo Photon Migration \
** -- OpenCL edition
** Author: Qianqian Fang <q.fang at neu.edu>
**
** Reference (Fang2009):
** Qianqian Fang and David A. Boas, "Monte Carlo Simulation of Photon
** Migration in 3D Turbid Media Accelerated by Graphics Processing
** Units," Optics Express, vol. 17, issue 22, pp. 20178-20190 (2009)
** \author Qianqian Fang <q.fang at neu.edu>
** \copyright Qianqian Fang, 2009-2018
**
** mcx_host.cpp: Host code for OpenCL
**
** Unpublished work, see LICENSE.txt for details
** \section sref Reference:
** \li \c (\b Yu2018) Leiming Yu, Fanny Nina-Paravecino, David Kaeli, and Qianqian Fang,
** "Scalable and massively parallel Monte Carlo photon transport simulations
** for heterogeneous computing platforms," J. Biomed. Optics, 23(1), 010504 (2018)
**
** \section slicense License
** GPL v3, see LICENSE.txt for details
*******************************************************************************/

#include <string.h>
Expand Down Expand Up @@ -423,7 +421,12 @@ void mcx_run_simulation(Config *cfg,float *fluence,float *totalenergy){

OCL_ASSERT(((mcxprogram=clCreateProgramWithSource(mcxcontext, 1,(const char **)&(cfg->clsource), NULL, &status),status)));

sprintf(opt,"-cl-mad-enable %s",cfg->compileropt);
if(cfg->optlevel>=1)
sprintf(opt,"%s ","-cl-mad-enable -DMCX_USE_NATIVE");
if(cfg->optlevel>=3)
sprintf(opt+strlen(opt),"%s ","-DMCX_SIMPLIFY_BRANCH -DMCX_VECTOR_INDEX");

sprintf(opt+strlen(opt),"%s",cfg->compileropt);
if(cfg->issavedet)
sprintf(opt+strlen(opt)," -D MCX_SAVE_DETECTORS");
if(cfg->isreflect)
Expand All @@ -444,7 +447,7 @@ void mcx_run_simulation(Config *cfg,float *fluence,float *totalenergy){
fprintf(cfg->flog,"Kernel build log:\n%s\n", msg);
break;
}
delete msg;
delete [] msg;
}
if(status!=CL_SUCCESS)
mcx_error(-(int)status,(char*)("Error: Failed to build program executable!"),__FILE__,__LINE__);
Expand Down
23 changes: 11 additions & 12 deletions src/mcx_shapes.c
@@ -1,17 +1,16 @@
/*******************************************************************************
**
** Monte Carlo eXtreme (MCX) - GPU accelerated 3D Monte Carlo transport simulation
** Author: Qianqian Fang <q.fang at neu.edu>
**
** Reference (Fang2009):
** Qianqian Fang and David A. Boas, "Monte Carlo Simulation of Photon
** Migration in 3D Turbid Media Accelerated by Graphics Processing
** Units," Optics Express, vol. 17, issue 22, pp. 20178-20190 (2009)
**
** mcx_shapes.c: 3D shape parsing and rasterization unit
/***************************************************************************//**
** \mainpage Monte Carlo eXtreme - GPU accelerated Monte Carlo Photon Migration \
** -- OpenCL edition
** \author Qianqian Fang <q.fang at neu.edu>
** \copyright Qianqian Fang, 2009-2018
**
** License: GNU General Public License v3, see LICENSE.txt for details
** \section sref Reference:
** \li \c (\b Yu2018) Leiming Yu, Fanny Nina-Paravecino, David Kaeli, and Qianqian Fang,
** "Scalable and massively parallel Monte Carlo photon transport simulations
** for heterogeneous computing platforms," J. Biomed. Optics, 23(1), 010504 (2018)
**
** \section slicense License
** GPL v3, see LICENSE.txt for details
*******************************************************************************/

/***************************************************************************//**
Expand Down
23 changes: 14 additions & 9 deletions src/mcx_test_nextafter.cl
@@ -1,12 +1,17 @@
////////////////////////////////////////////////////////////////////////////////
//
// Monte Carlo eXtreme (MCX) - GPU accelerated Monte Carlo 3D photon migration
// -- OpenCL edition
// Author: Qianqian Fang <q.fang at neu.edu>
//
// test unit for nextafter
//
////////////////////////////////////////////////////////////////////////////////
/***************************************************************************//**
** \mainpage Monte Carlo eXtreme - GPU accelerated Monte Carlo Photon Migration \
** -- OpenCL edition
** \author Qianqian Fang <q.fang at neu.edu>
** \copyright Qianqian Fang, 2009-2018
**
** \section sref Reference:
** \li \c (\b Yu2018) Leiming Yu, Fanny Nina-Paravecino, David Kaeli, and Qianqian Fang,
** "Scalable and massively parallel Monte Carlo photon transport simulations
** for heterogeneous computing platforms," J. Biomed. Optics, 23(1), 010504 (2018)
**
** \section slicense License
** GPL v3, see LICENSE.txt for details
*******************************************************************************/

#ifdef USE_HALF
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
Expand Down
50 changes: 28 additions & 22 deletions src/mcx_utils.c
@@ -1,18 +1,21 @@
/*******************************************************************************
**
** Monte Carlo eXtreme (MCX) - GPU accelerated Monte Carlo 3D photon migration
/***************************************************************************//**
** \mainpage Monte Carlo eXtreme - GPU accelerated Monte Carlo Photon Migration \
** -- OpenCL edition
** Author: Qianqian Fang <q.fang at neu.edu>
**
** Reference (Fang2009):
** Qianqian Fang and David A. Boas, "Monte Carlo Simulation of Photon
** Migration in 3D Turbid Media Accelerated by Graphics Processing
** Units," Optics Express, vol. 17, issue 22, pp. 20178-20190 (2009)
**
** mcx_utils.c: configuration and command line option processing unit
** \author Qianqian Fang <q.fang at neu.edu>
** \copyright Qianqian Fang, 2009-2018
**
** Unpublished work, see LICENSE.txt for details
** \section sref Reference:
** \li \c (\b Yu2018) Leiming Yu, Fanny Nina-Paravecino, David Kaeli, and Qianqian Fang,
** "Scalable and massively parallel Monte Carlo photon transport simulations
** for heterogeneous computing platforms," J. Biomed. Optics, 23(1), 010504 (2018)
**
** \section slicense License
** GPL v3, see LICENSE.txt for details
*******************************************************************************/

/***************************************************************************//**
\file mcx_utils.c
@brief mcconfiguration and command line option processing unit
*******************************************************************************/

#include <stdio.h>
Expand All @@ -37,14 +40,14 @@


char shortopt[]={'h','i','f','n','m','t','T','s','a','g','b','B','D','-','G','W','z',
'd','r','S','p','e','U','R','l','L','M','I','o','c','k','v','J',
'd','r','S','p','e','U','R','l','L','M','I','-','o','c','k','v','J',
'A','P','E','F','H','-','u','\0'};
const char *fullopt[]={"--help","--interactive","--input","--photon","--move",
"--thread","--blocksize","--session","--array","--gategroup",
"--reflect","--reflect3","--device","--devicelist","--gpu","--workload","--srcfrom0",
"--savedet","--repeat","--save2pt","--printlen","--minenergy",
"--normalize","--skipradius","--log","--listgpu","--dumpmask",
"--printgpu","--root","--cpu","--kernel","--verbose","--compileropt",
"--printgpu","--root","--optlevel","--cpu","--kernel","--verbose","--compileropt",
"--autopilot","--shapes","--seed","--outputformat","--maxdetphoton",
"--mediabyte","--unitinmm",""};
#ifdef WIN32
Expand Down Expand Up @@ -97,6 +100,7 @@ void mcx_initcfg(Config *cfg){
cfg->isdumpmask=0;
cfg->autopilot=0;
cfg->shapedata=NULL;
cfg->optlevel=3;

memset(cfg->deviceid,0,MAX_DEVICE);
memset(cfg->compileropt,0,MAX_PATH_LENGTH);
Expand Down Expand Up @@ -1188,7 +1192,7 @@ void mcx_parsecmd(int argc, char* argv[], Config *cfg){
cfg->isverbose=1;
break;
case 'o':
i=mcx_readarg(argc,argv,i,cfg->rootpath,"string");
i=mcx_readarg(argc,argv,i,&(cfg->optlevel),"int");
break;
case 'k':
i=mcx_readarg(argc,argv,i,cfg->kernelfile,"string");
Expand Down Expand Up @@ -1237,6 +1241,8 @@ void mcx_parsecmd(int argc, char* argv[], Config *cfg){
i=mcx_readarg(argc,argv,i,cfg->deviceid,"string");
else if(strcmp(argv[i]+2,"mediabyte")==0)
i=mcx_readarg(argc,argv,i,&(cfg->mediabyte),"int");
else if(strcmp(argv[i]+2,"root")==0)
i=mcx_readarg(argc,argv,i,cfg->rootpath,"string");
else
fprintf(cfg->flog,"unknown verbose option: --%s\n",argv[i]+2);
break;
Expand Down Expand Up @@ -1340,21 +1346,21 @@ int mcx_isbinstr(const char * str){
void mcx_printheader(Config *cfg){
fprintf(cfg->flog,"\
==============================================================================\n\
= Monte Carlo eXtreme (MCX) -- OpenCL =\n\
= Copyright (c) 2010-2017 Qianqian Fang <q.fang at neu.edu> =\n\
= http://mcx.space/ =\n\
= Monte Carlo eXtreme (MCX) -- OpenCL =\n\
= Copyright (c) 2010-2018 Qianqian Fang <q.fang at neu.edu> =\n\
= http://mcx.space/ =\n\
= =\n\
= Computational Optics & Translational Imaging (COTI) Lab- http://fanglab.or =\n\
= Department of Bioengineering, Northeastern University =\n\
= Computational Optics&Translational Imaging (COTI) Lab - http://fanglab.org =\n\
= Department of Bioengineering, Northeastern University =\n\
==============================================================================\n\
= The MCX Project is funded by the NIH/NIGMS under grant R01-GM114365 =\n\
= The MCX Project is funded by the NIH/NIGMS under grant R01-GM114365 =\n\
==============================================================================\n\
$Rev::6e839e $ Last $Date::2017-07-20 12:46:23 -04$ by $Author::Qianqian Fang$\n\
==============================================================================\n");
}

void mcx_usage(Config *cfg,char *exename){
mcx_printheader(cfg);
mcx_printheader(cfg);
printf("\n\
usage: %s <param1> <param2> ...\n\
where possible parameters include (the first item in [] is the default value)\n\
Expand Down
1 change: 1 addition & 0 deletions src/mcx_utils.h
Expand Up @@ -133,6 +133,7 @@ typedef struct MCXConfig{
unsigned int detectedcount; /**<total number of detected photons*/
unsigned int runtime;
int parentid;
uint optlevel;
void *seeddata;
uint mediabyte;
} Config;
Expand Down
24 changes: 12 additions & 12 deletions src/mcxcl.c
@@ -1,17 +1,17 @@
/*******************************************************************************
/***************************************************************************//**
** \mainpage Monte Carlo eXtreme - GPU accelerated Monte Carlo Photon Migration \
** -- OpenCL edition
** \author Qianqian Fang <q.fang at neu.edu>
** \copyright Qianqian Fang, 2009-2018
**
** Monte Carlo eXtreme - GPU accelerated Monte Carlo Photon Migration
**
** Author : Qianqian Fang
** Email : <q.fang at neu.edu>
** Institution: Department of Bioengineering, Northeastern University
** Address : ISEC 223, 360 Huntington Ave, Boston, MA 02115
** Homepage : http://fanglab.org
**
** MCX Web : http://mcx.space
**
** Unpublished work, see LICENSE.txt
** \section sref Reference:
** \li \c (\b Yu2018) Leiming Yu, Fanny Nina-Paravecino, David Kaeli, and Qianqian Fang,
** "Scalable and massively parallel Monte Carlo photon transport
** simulations for heterogeneous computing platforms," J. Biomed. Optics,
** 23(1), 010504 (2018)
**
** \section slicense License
** GPL v3, see LICENSE.txt for details
*******************************************************************************/

#include <stdio.h>
Expand Down
23 changes: 11 additions & 12 deletions src/tictoc.c
@@ -1,17 +1,16 @@
/*******************************************************************************
/***************************************************************************//**
** \mainpage Monte Carlo eXtreme - GPU accelerated Monte Carlo Photon Migration \
** -- OpenCL edition
** \author Qianqian Fang <q.fang at neu.edu>
** \copyright Qianqian Fang, 2009-2018
**
** Monte Carlo eXtreme (MCX) - GPU accelerated Monte Carlo 3D photon migration
** Author: Qianqian Fang <q.fang at neu.edu>
**
** Reference (Fang2009):
** Qianqian Fang and David A. Boas, "Monte Carlo Simulation of Photon
** Migration in 3D Turbid Media Accelerated by Graphics Processing
** Units," Optics Express, vol. 17, issue 22, pp. 20178-20190 (2009)
**
** tictoc.c: timing functions
**
** License: GNU General Public License v3, see LICENSE.txt for details
** \section sref Reference:
** \li \c (\b Yu2018) Leiming Yu, Fanny Nina-Paravecino, David Kaeli, and Qianqian Fang,
** "Scalable and massively parallel Monte Carlo photon transport simulations
** for heterogeneous computing platforms," J. Biomed. Optics, 23(1), 010504 (2018)
**
** \section slicense License
** GPL v3, see LICENSE.txt for details
*******************************************************************************/

#include "tictoc.h"
Expand Down

0 comments on commit d7a1a2f

Please sign in to comment.