11#include <jaffarCommon/exceptions.hpp>
12#include <jaffarCommon/parallel.hpp>
27static std::vector<std::vector<size_t>>
47 _threadCount = jaffarCommon::parallel::getMaxThreadCount();
56 const auto numaAvailable = numa_available();
57 if (numaAvailable != 0) JAFFAR_THROW_RUNTIME(
"The system does not provide NUMA detection support.");
60 if (
auto* value = std::getenv(
"JAFFAR_ENGINE_OVERRIDE_MAX_THREAD_COUNT")) jaffarCommon::parallel::setThreadCount(std::stoul(value));
83 std::map<size_t, std::vector<int>> _localPreferenceMap;
87 for (
const auto& entry : _localPreferenceMap)
89 const auto& localPreferenceGroup = entry.second;
90 for (ssize_t j = 0; j < (ssize_t)localPreferenceGroup.size(); j++)
92 const size_t offset = (j + i) % localPreferenceGroup.size();
114 std::mutex workMutex;
123 _myThreadId = jaffarCommon::parallel::getThreadId();
static thread_local int _preferredNumaDomain
Thread-local preferred NUMA domain (the NUMA node of the CPU the thread currently runs on).
static int _numaCount
Number of NUMA domains detected.
static std::vector< std::vector< size_t > > _numaPreferenceMatrix
NUMA preference matrix; row i lists domains ordered by ascending distance from domain i (ties rotated...
void initializeNUMA()
Initializes NUMA / core-affinity state.
static int _threadCount
Number of threads to use.
static std::vector< std::vector< size_t > > _numaDistanceMatrix
NUMA distance matrix; entry [i][j] is the reported distance from domain i to domain j.
static std::vector< ssize_t > _numaDelegateThreadId
Delegate thread (OpenMP thread id) per NUMA domain, or -1 if none assigned.
static thread_local int _myThreadId
Thread-local dense OpenMP thread id of the current thread.