3 #include <goofit/Version.h> 5 #include <thrust/detail/config/device_system.h> 8 #include <x86/cpu_x86.h> 15 #if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA 16 #include <cuda_runtime.h> 19 #if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_OMP || THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_TBB 27 std::cout <<
"GooFit: Control-C detected, exiting..." <<
reset << std::endl;
36 std::string splash = R
"raw( 38 ██╔════╝ █████╗ █████╗ ██╔═════╝ ██╗ 39 ██║ ███╗██╔══██╗██╔══██╗█████╗██╗██████╗ 40 ██║ ██║██║ ██║██║ ██║██╔══╝██║╚═██╔═╝ 41 ╚██████╔╝╚█████╔╝╚█████╔╝██║ ██║ ██║ 42 ╚═════╝ ╚════╝ ╚════╝ ╚═╝ ╚═╝ ██║ 49 bool cur_green =
false;
50 for(
int i = 0; i < splash.size(); i++) {
51 std::string letter = splash.substr(i, 3);
53 = letter ==
"╚" || letter ==
"╝" || letter ==
"╗" || letter ==
"╔" || letter ==
"║" || letter ==
"═";
54 bool is_block = letter ==
"█";
56 if(is_block && !cur_green) {
59 }
else if(is_edge && cur_green) {
63 std::cout << splash[i];
65 std::cout << std::flush;
68 std::cout <<
" GooFit\n";
71 std::cout <<
reset << std::flush;
75 GOOFIT_INFO(
"GooFit: Version {} ({}) Commit: {}", GOOFIT_VERSION, GOOFIT_TAG, GOOFIT_GIT_VERSION);
77 #if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA 78 cudaDeviceProp devProp;
79 cudaGetDeviceProperties(&devProp, gpuDev_);
81 GOOFIT_INFO(
"CUDA: Device {}: {}", gpuDev_, devProp.name);
83 GOOFIT_INFO(
"CUDA: Compute {}.{}", devProp.major, devProp.minor);
84 GOOFIT_INFO(
"CUDA: Total global memory: {} GB", devProp.totalGlobalMem / 1.0e9);
85 GOOFIT_INFO(
"CUDA: Multiprocessors: {}", devProp.multiProcessorCount);
87 GOOFIT_DEBUG(
"CUDA: Total amount of shared memory per block: {}", devProp.sharedMemPerBlock);
88 GOOFIT_DEBUG(
"CUDA: Total registers per block: {}", devProp.regsPerBlock);
90 GOOFIT_DEBUG(
"CUDA: Maximum memory pitch: {}", devProp.memPitch);
91 GOOFIT_DEBUG(
"CUDA: Total amount of constant memory: {}", devProp.totalConstMem);
93 #elif THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_OMP 94 GOOFIT_INFO(
"OMP: Number of threads: {}", omp_get_max_threads());
95 #elif THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_TBB 97 #elif THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CPP 101 #if GOOFIT_ROOT_FOUND 109 FeatureDetector::cpu_x86::print_warnings();
112 #if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA 114 cudaGetDeviceCount(&deviceCount);
116 for(
int i = 0; i < deviceCount; i++) {
117 cudaDeviceProp deviceProp;
118 cudaGetDeviceProperties(&deviceProp, i);
119 GOOFIT_INFO(
"CUDA: Device {} has compute capability {}.{}", i, deviceProp.major, deviceProp.minor);
132 MPI_Comm_size(MPI_COMM_WORLD, &numProcs);
133 MPI_Comm_rank(MPI_COMM_WORLD, &myId);
135 #if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA 137 cudaGetDeviceCount(&deviceCount);
140 auto PBS_NUM_NODES = getenv(
"PBS_NUM_NODES");
142 int nodes = PBS_NUM_NODES ==
nullptr ? 1 : atoi(PBS_NUM_NODES);
147 int procsPerNode = numProcs / nodes;
148 int localRank = myId % procsPerNode;
151 if(deviceCount == 1 && localRank > 1) {
154 }
else if(procsPerNode > 1 && deviceCount > 1) {
155 if(localRank <= deviceCount) {
160 gpuDev_ = localRank % deviceCount;
167 std::cout <<
"MPI using CUDA device: " <<
gpuDev_ << std::endl;
175 #if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA 177 add_option(
"--gpu-dev",
gpuDev_,
"GPU device to use",
true)->group(
"GooFit");
179 add_flag(
"--show-gpus",
show_gpus_,
"Show the available GPU devices and exit")->group(
"GooFit");
181 auto quiet = add_flag(
"-q,--quiet",
quiet_,
"Reduce the verbosity of the Application")->group(
"GooFit");
183 add_flag(
"--nosplash",
splash_,
"Do not print a splash")->group(
"GooFit")->excludes(quiet);
185 set_config(
"--config",
"config.ini",
"An ini file with command line options in it")->group(
"GooFit");
209 #if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA 219 MPI_Comm_rank(MPI_COMM_WORLD, &myId);
222 return e.get_exit_code();
225 std::cout << (e.get_exit_code() == 0 ?
blue :
red);
226 int rval = CLI::App::exit(e);
242 if(CLI::ExistingFile(input_str).empty())
246 std::string prog_name{
argv_[0]};
247 size_t loc = prog_name.rfind(
"/");
248 if(loc != std::string::npos) {
249 std::string cdir = prog_name.substr(0, loc);
250 std::string new_input{cdir +
"/" + input_str};
251 if(CLI::ExistingFile(new_input).empty()) {
252 std::cout <<
"Found file at " << new_input << std::endl;
258 if(base.size() > 0) {
259 std::string new_input = std::string(GOOFIT_SOURCE_DIR) +
"/" + base +
"/" + input_str;
260 if(CLI::ExistingFile(new_input).empty()) {
261 std::cout <<
"Found file at " << new_input << std::endl;
267 throw GooFit::FileError(input_str);
void signal_handler(int s)
will call the correct exit func, no unwinding of the stack though
~Application() override
Cleanup MPI if needed.
void print_goofit_info(int gpuDev_=0)
Print out information about GooFit.
struct sigaction sigIntHandler
Handle control-c codes.
constexpr rang::style const bold
constexpr rang::fg const blue
constexpr rang::fg const red
int exit(const CLI::Error &e)
Exit.
void pre_callback() override
Gets called in parse.
#define GOOFIT_DEBUG(...)
Application(std::string discription, int argc, char **argv)
Make a new Application.
constexpr rang::style const dim
constexpr rang::style const reset
constexpr rang::fg const green
std::string get_filename(const std::string &input_str, std::string base="") const