ThreadSchedule 3.0.0
Modern C++ thread management library
Loading...
Searching...
No Matches
cpu_topology.hpp File Reference

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

#include "../thread_affinity.hpp"
#include <algorithm>
#include <charconv>
#include <cstdint>
#include <string_view>
#include <thread>
#include <vector>
#include <fstream>
#include <string>
Include dependency graph for cpu_topology.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

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

Namespaces

namespace  threadschedule
 
namespace  threadschedule::advanced
 
namespace  threadschedule::advanced::topology_detail
 

Functions

auto threadschedule::advanced::topology_detail::parse_index_list (std::string_view input) -> std::vector< int >
 
auto threadschedule::advanced::topology_detail::read_index_list (std::string const &path) -> std::vector< int >
 
auto threadschedule::advanced::read_topology () -> cpu_topology
 Discover basic topology. Linux: reads /sys for NUMA nodes. Windows: single node, processor-group-aware CPU indices.
 
auto threadschedule::advanced::affinity_for_node (cpu_topology const &topo, int node_index, int thread_index, int threads_per_node=1) -> thread_affinity
 Build a thread_affinity for the given NUMA node using a pre-read topology.
 
auto threadschedule::advanced::affinity_for_node (int node_index, int thread_index, int threads_per_node=1) -> thread_affinity
 Build a thread_affinity for the given NUMA node.
 
auto threadschedule::advanced::distribute_affinities_by_numa (cpu_topology const &topo, size_t num_threads) -> std::vector< thread_affinity >
 Distribute thread affinities across NUMA nodes in round-robin order.
 
auto threadschedule::advanced::distribute_affinities_by_numa (size_t num_threads) -> std::vector< thread_affinity >
 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 thread_affinity masks. On Linux, NUMA nodes are detected via sysfs (nodeX/cpulist). On Windows, processor groups are enumerated and represented as flat group*64+index IDs.

Definition in file cpu_topology.hpp.