Thread System 0.3.1
High-performance C++20 thread pool with work stealing and DAG scheduling
Loading...
Searching...
No Matches
numa_thread_pool.cpp
Go to the documentation of this file.
1// BSD 3-Clause License
2// Copyright (c) 2024, 🍀☀🌕🌥 🌊
3// See the LICENSE file in the project root for full license information.
4
7
8namespace kcenon::thread {
9
10numa_thread_pool::numa_thread_pool(const std::string& thread_title,
11 const thread_context& context)
12 : thread_pool(thread_title, context) {
13 // Eagerly detect topology on construction
15}
16
17numa_thread_pool::numa_thread_pool(const std::string& thread_title,
18 std::shared_ptr<job_queue> custom_queue,
19 const thread_context& context)
20 : thread_pool(thread_title, std::move(custom_queue), context) {
22}
23
24numa_thread_pool::numa_thread_pool(const std::string& thread_title,
25 std::unique_ptr<pool_queue_adapter_interface> queue_adapter,
26 const thread_context& context)
27 : thread_pool(thread_title, std::move(queue_adapter), context) {
29}
30
32 enhanced_ws_config_ = config;
34
35 if (config.enabled) {
36 if (cached_topology_.node_count() == 0) {
38 }
39 // Note: Full work stealer setup is done in start() or when workers are added
40 }
41}
42
46
53
58
63
67
73
77
84
85} // namespace kcenon::thread
const numa_topology & numa_topology_info() const
Get the detected NUMA topology.
enhanced_work_stealing_config enhanced_ws_config_
Enhanced work-stealing configuration.
bool is_numa_system() const
Check if the system has NUMA architecture.
worker_policy worker_policy_
Worker policy configuration.
bool topology_detected_
Flag indicating if topology has been detected.
bool is_numa_work_stealing_enabled() const
Check if NUMA work stealing is currently enabled.
numa_topology cached_topology_
Cached NUMA topology (detected on construction)
void enable_numa_work_stealing()
Enable NUMA-optimized work stealing with default settings.
const enhanced_work_stealing_config & numa_work_stealing_config() const
Get the current NUMA work-stealing configuration.
void configure_numa_work_stealing(const enhanced_work_stealing_config &config)
Configure NUMA-aware work stealing.
std::unique_ptr< numa_work_stealer > numa_work_stealer_
NUMA-aware work stealer.
void disable_numa_work_stealing()
Disable NUMA-aware work stealing.
void ensure_topology_detected() const
Ensure topology is detected.
work_stealing_stats_snapshot numa_work_stealing_stats() const
Get a snapshot of NUMA work-stealing statistics.
NUMA (Non-Uniform Memory Access) topology information.
static auto detect() -> numa_topology
Detect and return the system's NUMA topology.
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.
Context object that provides access to optional services.
A thread pool for concurrent execution of jobs using multiple worker threads.
Core threading foundation of the thread system library.
Definition thread_impl.h:17
STL namespace.
NUMA-aware thread pool optimized for Non-Uniform Memory Access architectures.
NUMA-aware work stealer with enhanced victim selection policies.
Configuration for enhanced work-stealing with NUMA awareness.
bool numa_aware
Enable NUMA-aware stealing (default: disabled)
static auto numa_optimized() -> enhanced_work_stealing_config
Create a configuration optimized for NUMA systems.
bool enabled
Master switch for work-stealing (default: disabled)
Non-atomic snapshot of work-stealing statistics.