31void loadWithErrorChecking(
const std::string &libName)
33 const auto returnValue =
gSystem->Load(libName.c_str());
34 if (returnValue == -1 || returnValue == -2) {
35 throw std::runtime_error(
"RooFit was unable to load its computation library " + libName);
39bool &isInitialisedCpu()
41 static bool isInitialised =
false;
53 if (isInitialisedCpu())
57#ifdef R__RF_ARCHITECTURE_SPECIFIC_LIBS
60 bool supported_avx512 = __builtin_cpu_supports(
"avx512cd") && __builtin_cpu_supports(
"avx512vl") &&
61 __builtin_cpu_supports(
"avx512bw") && __builtin_cpu_supports(
"avx512dq");
63 if (userChoice ==
"auto") {
64 if (supported_avx512) {
65 loadWithErrorChecking(
"libRooBatchCompute_AVX512");
66 }
else if (__builtin_cpu_supports(
"avx2")) {
67 loadWithErrorChecking(
"libRooBatchCompute_AVX2");
68 }
else if (__builtin_cpu_supports(
"avx")) {
69 loadWithErrorChecking(
"libRooBatchCompute_AVX");
70 }
else if (__builtin_cpu_supports(
"sse4.1")) {
71 loadWithErrorChecking(
"libRooBatchCompute_SSE4.1");
73 }
else if (userChoice ==
"avx512") {
74 loadWithErrorChecking(
"libRooBatchCompute_AVX512");
75 }
else if (userChoice ==
"avx2") {
76 loadWithErrorChecking(
"libRooBatchCompute_AVX2");
77 }
else if (userChoice ==
"avx") {
78 loadWithErrorChecking(
"libRooBatchCompute_AVX");
79 }
else if (userChoice ==
"sse") {
80 loadWithErrorChecking(
"libRooBatchCompute_SSE4.1");
81 }
else if (userChoice !=
"generic") {
82 throw std::invalid_argument(
83 R
"(Supported options for "RooFit.BatchCompute" are "auto", "avx512", "avx2", "avx", "sse", "generic".)");
88 loadWithErrorChecking(
"libRooBatchCompute_GENERIC");
90 isInitialisedCpu() =
true;
98 static bool isInitialised =
false;
101 isInitialised =
true;
103 return gSystem->Load(
"libRooBatchCompute_CUDA");
108 return gEnv->GetValue(
"RooFit.BatchCompute",
"generic");
114 throw std::runtime_error(
"It is not possible to choose a different BatchCompute library after RooBatchCompute "
115 "was already initialised!");
117 gEnv->SetValue(
"RooFit.BatchCompute", value.c_str());
The interface which should be implemented to provide optimised computation functions for implementati...
Namespace for dispatching RooFit computations to various backends.
R__EXTERN RooBatchComputeInterface * dispatchCUDA
std::string getBatchComputeChoice()
R__EXTERN RooBatchComputeInterface * dispatchCPU
This dispatch pointer points to an implementation of the compute library, provided one has been loade...
void setBatchComputeChoice(std::string const &value)
int initCPU()
Inspect hardware capabilities, and load the optimal library for RooFit computations.