|
Thread System 0.3.1
High-performance C++20 thread pool with work stealing and DAG scheduling
|
NUMA (Non-Uniform Memory Access) topology information. More...
#include <numa_topology.h>

Public Member Functions | |
| numa_topology ()=default | |
| Default constructor - creates an empty topology. | |
| auto | get_node_for_cpu (int cpu_id) const -> int |
| Get the NUMA node for a given CPU. | |
| auto | get_distance (int node1, int node2) const -> int |
| Get the distance between two NUMA nodes. | |
| auto | is_same_node (int cpu1, int cpu2) const -> bool |
| Check if two CPUs are on the same NUMA node. | |
| auto | is_numa_available () const -> bool |
| Check if NUMA is available on this system. | |
| auto | node_count () const -> std::size_t |
| Get the number of NUMA nodes. | |
| auto | cpu_count () const -> std::size_t |
| Get the total number of CPUs. | |
| auto | get_nodes () const -> const std::vector< numa_node > & |
| Get all NUMA nodes. | |
| auto | get_cpus_for_node (int node_id) const -> std::vector< int > |
| Get CPUs belonging to a specific node. | |
Static Public Member Functions | |
| static auto | detect () -> numa_topology |
| Detect and return the system's NUMA topology. | |
Static Private Member Functions | |
| static auto | detect_linux () -> numa_topology |
| Detect topology on Linux using sysfs. | |
| static auto | create_fallback () -> numa_topology |
| Create fallback single-node topology. | |
Private Attributes | |
| std::vector< numa_node > | nodes_ |
| All NUMA nodes. | |
| std::vector< int > | cpu_to_node_ |
| CPU ID -> NUMA node mapping. | |
| std::vector< std::vector< int > > | distances_ |
| Inter-node distances. | |
| std::size_t | total_cpus_ {0} |
| Total CPU count. | |
NUMA (Non-Uniform Memory Access) topology information.
This class provides information about the system's NUMA topology, including the number of NUMA nodes, which CPUs belong to which nodes, and the distances between nodes.
All methods are thread-safe after construction. The topology is detected once during construction and remains immutable.
Definition at line 67 of file numa_topology.h.
|
default |
Default constructor - creates an empty topology.
|
nodiscard |
Get the total number of CPUs.
Definition at line 81 of file numa_topology.cpp.
References total_cpus_.
|
staticprivate |
Create fallback single-node topology.
Definition at line 274 of file numa_topology.cpp.
References kcenon::thread::numa_node::cpu_ids, cpu_to_node_, distances_, kcenon::thread::numa_node::memory_size_bytes, kcenon::thread::numa_node::node_id, nodes_, and total_cpus_.
|
staticnodiscard |
Detect and return the system's NUMA topology.
This static method detects the NUMA topology of the current system. On non-NUMA systems or unsupported platforms, it returns a single-node topology with all CPUs.
Definition at line 21 of file numa_topology.cpp.
Referenced by kcenon::thread::numa_thread_pool::ensure_topology_detected().

|
staticprivate |
Detect topology on Linux using sysfs.
|
nodiscard |
Get CPUs belonging to a specific node.
| node_id | NUMA node ID |
Definition at line 91 of file numa_topology.cpp.
|
nodiscard |
Get the distance between two NUMA nodes.
| node1 | First NUMA node ID |
| node2 | Second NUMA node ID |
The distance is a relative measure where:
Definition at line 40 of file numa_topology.cpp.
|
nodiscard |
Get the NUMA node for a given CPU.
| cpu_id | The CPU identifier |
Definition at line 31 of file numa_topology.cpp.
|
nodiscard |
Get all NUMA nodes.
Definition at line 86 of file numa_topology.cpp.
References nodes_.
|
nodiscard |
Check if NUMA is available on this system.
Definition at line 71 of file numa_topology.cpp.
References nodes_.
Referenced by kcenon::thread::numa_thread_pool::is_numa_system().

|
nodiscard |
Check if two CPUs are on the same NUMA node.
| cpu1 | First CPU ID |
| cpu2 | Second CPU ID |
Definition at line 58 of file numa_topology.cpp.
|
nodiscard |
Get the number of NUMA nodes.
Definition at line 76 of file numa_topology.cpp.
References nodes_.
Referenced by kcenon::thread::numa_thread_pool::configure_numa_work_stealing().

|
private |
CPU ID -> NUMA node mapping.
Definition at line 145 of file numa_topology.h.
Referenced by create_fallback().
|
private |
Inter-node distances.
Definition at line 146 of file numa_topology.h.
Referenced by create_fallback().
|
private |
All NUMA nodes.
Definition at line 144 of file numa_topology.h.
Referenced by create_fallback(), get_nodes(), is_numa_available(), and node_count().
|
private |
Total CPU count.
Definition at line 147 of file numa_topology.h.
Referenced by cpu_count(), and create_fallback().