JaffarPlus
High-performance best-first search optimizer for tool-assisted speedruns
Loading...
Searching...
No Matches
numa.hpp File Reference

NUMA topology detection: distance/preference matrices and per-domain delegate-thread selection, identifying threads by OpenMP thread id and using sched_getcpu only for the NUMA domain lookup. More...

#include <cstdlib>
#include <jaffarCommon/exceptions.hpp>
#include <jaffarCommon/parallel.hpp>
#include <map>
#include <mutex>
#include <numa.h>
#include <vector>

Go to the source code of this file.

Functions

void jaffarPlus::initializeNUMA ()
 Initializes NUMA / core-affinity state.
 

Variables

static int jaffarPlus::_numaCount
 Number of NUMA domains detected.
 
static int jaffarPlus::_threadCount
 Number of threads to use.
 
static std::vector< std::vector< size_t > > jaffarPlus::_numaDistanceMatrix
 NUMA distance matrix; entry [i][j] is the reported distance from domain i to domain j.
 
static std::vector< std::vector< size_t > > jaffarPlus::_numaPreferenceMatrix
 NUMA preference matrix; row i lists domains ordered by ascending distance from domain i (ties rotated per source domain).
 
static std::vector< ssize_t > jaffarPlus::_numaDelegateThreadId
 Delegate thread (OpenMP thread id) per NUMA domain, or -1 if none assigned.
 
static thread_local int jaffarPlus::_preferredNumaDomain
 Thread-local preferred NUMA domain (the NUMA node of the CPU the thread currently runs on).
 
static thread_local int jaffarPlus::_myThreadId
 Thread-local dense OpenMP thread id of the current thread.
 

Detailed Description

NUMA topology detection: distance/preference matrices and per-domain delegate-thread selection, identifying threads by OpenMP thread id and using sched_getcpu only for the NUMA domain lookup.

Definition in file numa.hpp.

Function Documentation

◆ initializeNUMA()

void jaffarPlus::initializeNUMA ( )

Initializes NUMA / core-affinity state.

Detects the thread count and NUMA domain count, optionally overrides the thread count from the JAFFAR_ENGINE_OVERRIDE_MAX_THREAD_COUNT environment variable, builds the NUMA distance and preference matrices, and selects one delegate thread per NUMA domain. Each worker identifies itself by its OpenMP thread id and derives its preferred NUMA domain from sched_getcpu.

Exceptions
Aruntime error if the system does not provide NUMA detection support.

Definition at line 44 of file numa.hpp.

Variable Documentation

◆ _myThreadId

thread_local int jaffarPlus::_myThreadId
static

Thread-local dense OpenMP thread id of the current thread.

Definition at line 34 of file numa.hpp.

◆ _numaCount

int jaffarPlus::_numaCount
static

Number of NUMA domains detected.

Definition at line 21 of file numa.hpp.

◆ _numaDelegateThreadId

std::vector<ssize_t> jaffarPlus::_numaDelegateThreadId
static

Delegate thread (OpenMP thread id) per NUMA domain, or -1 if none assigned.

Definition at line 30 of file numa.hpp.

◆ _numaDistanceMatrix

std::vector<std::vector<size_t> > jaffarPlus::_numaDistanceMatrix
static

NUMA distance matrix; entry [i][j] is the reported distance from domain i to domain j.

Definition at line 25 of file numa.hpp.

◆ _numaPreferenceMatrix

std::vector<std::vector<size_t> > jaffarPlus::_numaPreferenceMatrix
static

NUMA preference matrix; row i lists domains ordered by ascending distance from domain i (ties rotated per source domain).

Definition at line 28 of file numa.hpp.

◆ _preferredNumaDomain

thread_local int jaffarPlus::_preferredNumaDomain
static

Thread-local preferred NUMA domain (the NUMA node of the CPU the thread currently runs on).

Definition at line 32 of file numa.hpp.

◆ _threadCount

int jaffarPlus::_threadCount
static

Number of threads to use.

Definition at line 23 of file numa.hpp.