qualpal::Threads
C++ · cpp · 4.1.0
Centralized management of thread settings for parallel computations.
The Threads class provides a unified interface to control the number of threads used for parallel computations throughout qualpal. It supports both OpenMP and non-OpenMP builds:
When OpenMP is available, it sets and queries the OpenMP thread count.
When OpenMP is not available, all computations run sequentially (single-threaded).
By default, the thread count is set to half the number of available hardware threads (typically the number of physical CPU cores), but can be changed at runtime.
Note
This class is not thread-safe. Set the thread count before starting parallel work.
; // Set to use 4 threads
std::size_t n = ; // Get current thread countMethods
get
Source: include/qualpal/threads.h
static inline std::size_t Get the current number of threads used for parallel computations.
Returns
The current thread count as set by set(), or the default value.
set
Source: include/qualpal/threads.h
static inline void Set the number of threads to use for parallel computations.
Parameters
n
Number of threads. Must be positive.
Throws
std::invalid_argument
if n is zero.
Note
When OpenMP is enabled, this sets the OpenMP thread count globally.
