int main (int argc, char *argv[]) { Config mcxconfig; unsigned int activedev=0; float *fluence=NULL,totalenergy=0.f; mcx_initcfg(&mcxconfig); // parse command line options to initialize the configurations mcx_parsecmd(argc,argv,&mcxconfig); // identify gpu number and set one gpu active if(!mcx_set_gpu(&mcxconfig,&activedev)){ mcx_error(-1,"No compute platform was found\n",__FILE__,__LINE__); } if(activedev==0) return 0; mcx_createfluence(&fluence,&mcxconfig); // this launches the MC simulation mcx_run_simulation(&mcxconfig,fluence,&totalenergy); // clean up the allocated memory in the config mcx_clearfluence(&fluence); mcx_clearcfg(&mcxconfig); return 0; }
int main (int argc, char *argv[]) { /*! structure to store all simulation parameters */ Config mcxconfig; /** mcxconfig: structure to store all simulation parameters */ GPUInfo *gpuinfo=NULL; /** gpuinfo: structure to store GPU information */ unsigned int activedev=0; /** activedev: count of total active GPUs to be used */ /** To start an MCX simulation, we first create a simulation configuration and set all elements to its default settings. */ mcx_initcfg(&mcxconfig); /** Then, we parse the full command line parameters and set user specified settings */ mcx_parsecmd(argc,argv,&mcxconfig); /** The next step, we identify gpu number and query all GPU info */ if(!(activedev=mcx_list_gpu(&mcxconfig,&gpuinfo))){ mcx_error(-1,"No GPU device found\n",__FILE__,__LINE__); } #ifdef _OPENMP /** Now we are ready to launch one thread for each involked GPU to run the simulation */ omp_set_num_threads(activedev); #pragma omp parallel { #endif /** This line runs the main MCX simulation for each GPU inside each thread */ mcx_run_simulation(&mcxconfig,gpuinfo); #ifdef _OPENMP } #endif /** Once simulation is complete, we clean up the allocated memory in config and gpuinfo, and exit */ mcx_cleargpuinfo(&gpuinfo); mcx_clearcfg(&mcxconfig); return 0; }
int main (int argc, char *argv[]) { Config mcxconfig; mcx_initcfg(&mcxconfig); // parse command line options to initialize the configurations mcx_parsecmd(argc,argv,&mcxconfig); // identify gpu number and set one gpu active if(!mcx_set_gpu(&mcxconfig)){ mcx_error(-1,"No GPU device found\n",__FILE__,__LINE__); } // this launches the MC simulation mcx_run_simulation(&mcxconfig); // clean up the allocated memory in the config mcx_clearcfg(&mcxconfig); return 0; }
int main (int argc, char *argv[]) { Config mcxconfig; float *fluence=NULL,totalenergy=0.f; mcx_initcfg(&mcxconfig); // parse command line options to initialize the configurations mcx_parsecmd(argc,argv,&mcxconfig); mcx_createfluence(&fluence,&mcxconfig); // this launches the MC simulation mcx_run_simulation(&mcxconfig,fluence,&totalenergy); // clean up the allocated memory in the config mcx_clearfluence(&fluence); mcx_clearcfg(&mcxconfig); return 0; }