std::thread::hardware_concurrency (3) - Linux Manuals
std::thread::hardware_concurrency: std::thread::hardware_concurrency
NAME
std::thread::hardware_concurrency - std::thread::hardware_concurrency
Synopsis
static unsigned int hardware_concurrency() noexcept; (since C++11)
Returns the number of concurrent threads supported by the implementation. The value should be considered only a hint.
Parameters
(none)
Return value
Number of concurrent threads supported. If the value is not well defined or not computable, returns 0.
Example
// Run this code
Possible output:
See also
hardware_destructive_interference_size min offset to avoid false sharing
hardware_constructive_interference_size max offset to promote true sharing
(C++17)