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);
47 static bool isInitialised =
false;
52 const std::string userChoice =
gEnv->
GetValue(
"RooFit.BatchCompute",
"auto");
53#ifdef R__RF_ARCHITECTURE_SPECIFIC_LIBS
61#if __GNUC__ > 5 || defined(__clang__)
62 bool supported_avx512 = __builtin_cpu_supports(
"avx512cd") && __builtin_cpu_supports(
"avx512vl") &&
63 __builtin_cpu_supports(
"avx512bw") && __builtin_cpu_supports(
"avx512dq");
65 bool supported_avx512 =
false;
68 if (userChoice ==
"auto") {
70 loadWithErrorChecking(
"libRooBatchCompute_AVX512");
71 else if (__builtin_cpu_supports(
"avx2"))
72 loadWithErrorChecking(
"libRooBatchCompute_AVX2");
73 else if (__builtin_cpu_supports(
"avx"))
74 loadWithErrorChecking(
"libRooBatchCompute_AVX");
75 else if (__builtin_cpu_supports(
"sse4.1"))
76 loadWithErrorChecking(
"libRooBatchCompute_SSE4.1");
77 }
else if (userChoice ==
"avx512")
78 loadWithErrorChecking(
"libRooBatchCompute_AVX512");
79 else if (userChoice ==
"avx2")
80 loadWithErrorChecking(
"libRooBatchCompute_AVX2");
81 else if (userChoice ==
"avx")
82 loadWithErrorChecking(
"libRooBatchCompute_AVX");
83 else if (userChoice ==
"sse")
84 loadWithErrorChecking(
"libRooBatchCompute_SSE4.1");
85 else if (userChoice !=
"generic")
86 throw std::invalid_argument(
87 "Supported options for `RooFit.BatchCompute` are `auto`, `avx512`, `avx2`, `avx`, `sse`, `generic`.");
91 loadWithErrorChecking(
"libRooBatchCompute_GENERIC");
R__EXTERN TSystem * gSystem
The interface which should be implemented to provide optimised computation functions for implementati...
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Namespace for dispatching RooFit computations to various backends.
R__EXTERN RooBatchComputeInterface * dispatchCUDA
R__EXTERN RooBatchComputeInterface * dispatchCPU
This dispatch pointer points to an implementation of the compute library, provided one has been loade...
void init()
Inspect hardware capabilities, and load the optimal library for RooFit computations.