19void loadWithErrorChecking(
const std::string& libName)
21 const auto returnValue =
gSystem->
Load(libName.c_str());
22 if (returnValue == -1 || returnValue == -2) {
23 throw std::runtime_error(
"RooFit was unable to load its computation library " + libName);
24 }
else if (returnValue == 1) {
26 throw std::logic_error(
"RooFit computation library " + libName +
" was loaded before RooFit initialisation began.");
33void loadComputeLibrary() {
35#ifdef R__RF_ARCHITECTURE_SPECIFIC_LIBS
38 const std::string userChoice =
gEnv->
GetValue(
"RooFit.ComputationLibraryArch",
"auto");
39 if (userChoice!=
"auto" && userChoice!=
"avx512" && userChoice!=
"avx2" && userChoice!=
"avx" && userChoice!=
"sse4.1" && userChoice!=
"generic")
40 throw std::invalid_argument(
"Supported options for `RooFit.ComputationLibraryArch` are `auto`, `avx512`, `avx2`, `avx`, `sse4.1`, `generic`.");
43#if __GNUC__ > 5 || defined(__clang__)
44 if (__builtin_cpu_supports(
"avx512cd") && __builtin_cpu_supports(
"avx512vl") && __builtin_cpu_supports(
"avx512bw") && __builtin_cpu_supports(
"avx512dq")
45 && (userChoice==
"avx512" || userChoice==
"auto") ) {
46 loadWithErrorChecking(
"libRooBatchCompute_AVX512");
50 if (__builtin_cpu_supports(
"avx2") && (userChoice==
"avx2" || userChoice==
"auto")) {
51 loadWithErrorChecking(
"libRooBatchCompute_AVX2");
53 }
else if (__builtin_cpu_supports(
"avx") && (userChoice==
"avx" || userChoice==
"auto")) {
54 loadWithErrorChecking(
"libRooBatchCompute_AVX");
56 }
else if (__builtin_cpu_supports(
"sse4.1") && (userChoice==
"sse4.1" || userChoice==
"auto")) {
57 loadWithErrorChecking(
"libRooBatchCompute_SSE4.1");
64 std::cout <<
"In " << __func__ <<
"(), " << __FILE__ <<
":" << __LINE__ <<
": Vector instruction sets not supported, using generic implementation." << std::endl;
66 loadWithErrorChecking(
"libRooBatchCompute_GENERIC");
74static struct RooBatchComputeInitialiser {
75 RooBatchComputeInitialiser() {
R__EXTERN TSystem * gSystem
static struct RooBatchComputeInitialiser __RooBatchComputeInitialiser
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.
R__EXTERN RooBatchComputeInterface * dispatch
This dispatch pointer points to an implementation of the compute library, provided one has been loade...