30void loadWithErrorChecking(
const std::string &libName)
32 const auto returnValue =
gSystem->
Load(libName.c_str());
33 if (returnValue == -1 || returnValue == -2)
34 throw std::runtime_error(
"RooFit was unable to load its computation library " + libName);
35 else if (returnValue == 1)
36 throw std::logic_error(
"RooFit computation library " + libName +
37 " was loaded before RooFit initialisation began.");
48 static bool isInitialised =
false;
53 const std::string userChoice =
gEnv->
GetValue(
"RooFit.BatchCompute",
"auto");
54#ifdef R__RF_ARCHITECTURE_SPECIFIC_LIBS
62#if __GNUC__ > 5 || defined(__clang__)
63 bool supported_avx512 = __builtin_cpu_supports(
"avx512cd") && __builtin_cpu_supports(
"avx512vl") &&
64 __builtin_cpu_supports(
"avx512bw") && __builtin_cpu_supports(
"avx512dq");
66 bool supported_avx512 =
false;
69 if (userChoice ==
"auto") {
71 loadWithErrorChecking(
"libRooBatchCompute_AVX512");
72 else if (__builtin_cpu_supports(
"avx2"))
73 loadWithErrorChecking(
"libRooBatchCompute_AVX2");
74 else if (__builtin_cpu_supports(
"avx"))
75 loadWithErrorChecking(
"libRooBatchCompute_AVX");
76 else if (__builtin_cpu_supports(
"sse4.1"))
77 loadWithErrorChecking(
"libRooBatchCompute_SSE4.1");
78 }
else if (userChoice ==
"avx512")
79 loadWithErrorChecking(
"libRooBatchCompute_AVX512");
80 else if (userChoice ==
"avx2")
81 loadWithErrorChecking(
"libRooBatchCompute_AVX2");
82 else if (userChoice ==
"avx")
83 loadWithErrorChecking(
"libRooBatchCompute_AVX");
84 else if (userChoice ==
"sse")
85 loadWithErrorChecking(
"libRooBatchCompute_SSE4.1");
86 else if (userChoice !=
"generic")
87 throw std::invalid_argument(
88 "Supported options for `RooFit.BatchCompute` are `auto`, `avx512`, `avx2`, `avx`, `sse`, `generic`.");
92 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.