20#pragma GCC diagnostic ignored "-Wunknown-pragmas"
25#define omp_get_thread_num() 0
26#define omp_get_max_threads() 1
27#define omp_get_num_threads() 1
34 return use_omp ?
"Using OpenMP with " +
35 std::to_string(omp_get_max_threads()) +
" threads." :
63 if (omp_get_max_threads() > 1 && oblas_get() && oblas_set()) {
64 m_saved = oblas_get()();
81 using fn_set = void (*)(int);
82 using fn_get = int (*)();
84 static fn_set oblas_set() {
86 reinterpret_cast<fn_set
>(dlsym(RTLD_DEFAULT,
"openblas_set_num_threads"));
89 static fn_get oblas_get() {
91 reinterpret_cast<fn_get
>(dlsym(RTLD_DEFAULT,
"openblas_get_num_threads"));
Scoped guard: forces single-threaded BLAS (OpenBLAS) for the lifetime of the object; restores the pre...
Definition omp.hpp:59
General-purpose utility library.
Definition Array.hpp:23
constexpr bool use_omp
True if compiled with OpenMP support, false otherwise.
Definition omp.hpp:23
std::string omp_details()
Returns a short string describing the threading status, e.g. "Using OpenMP with 8 threads....
Definition omp.hpp:33