ThreadSchedule 1.0.0
Modern C++ thread management library
Loading...
Searching...
No Matches
topology.hpp File Reference

Hardware topology helpers (CPU count, NUMA nodes) and affinity builders. More...

#include "scheduler_policy.hpp"
#include <cctype>
#include <thread>
#include <vector>
#include <fstream>
#include <string>
#include <unistd.h>
Include dependency graph for topology.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  threadschedule::CpuTopology
 Snapshot of basic CPU/NUMA topology. More...

Functions

auto threadschedule::read_topology () -> CpuTopology
 Discover basic topology. Linux: reads /sys for NUMA nodes. Windows: single node, sequential CPU indices.
auto threadschedule::affinity_for_node (int node_index, int thread_index, int threads_per_node=1) -> ThreadAffinity
 Build a ThreadAffinity for the given NUMA node.
auto threadschedule::distribute_affinities_by_numa (size_t num_threads) -> std::vector< ThreadAffinity >
 Distribute thread affinities across NUMA nodes in round-robin order.

Detailed Description

Hardware topology helpers (CPU count, NUMA nodes) and affinity builders.

Exposes lightweight discovery of CPU/NUMA topology and convenience functions to construct NUMA-aware ThreadAffinity masks. On Linux, NUMA nodes are detected via sysfs (nodeX/cpulist). On Windows, nodes default to 1 and CPUs are assigned sequentially.

Definition in file topology.hpp.

Function Documentation

◆ affinity_for_node()

auto threadschedule::affinity_for_node ( int node_index,
int thread_index,
int threads_per_node = 1 ) -> ThreadAffinity
inline

Build a ThreadAffinity for the given NUMA node.

Parameters
node_indexNUMA node index (wraps if out of range)
thread_indexUsed to select CPU(s) within node
threads_per_nodeOptionally include multiple CPUs per thread

Definition at line 137 of file topology.hpp.

◆ distribute_affinities_by_numa()

auto threadschedule::distribute_affinities_by_numa ( size_t num_threads) -> std::vector<ThreadAffinity>
inline

Distribute thread affinities across NUMA nodes in round-robin order.

Definition at line 162 of file topology.hpp.

◆ read_topology()

auto threadschedule::read_topology ( ) -> CpuTopology
inline

Discover basic topology. Linux: reads /sys for NUMA nodes. Windows: single node, sequential CPU indices.

Definition at line 42 of file topology.hpp.