Utility to determine the optimal number of threads for the host system.
More...
#include <iostream>
#include <thread>
Go to the source code of this file.
|
| int | main () |
| | Main entry point.
|
| |
Utility to determine the optimal number of threads for the host system.
- This program queries the hardware to find the number of supported concurrent threads. This value is critical for avoiding over-subscription in Thread Pools.
Definition in file check_processors.cpp.
◆ main()
Main entry point.
- Returns
- 0 on success.
The number of concurrent threads supported by the implementation.
- The value should be considered a hint. If the value is not computable or well defined, this function returns 0.
Definition at line 15 of file check_processors.cpp.
15 {
16
17
18
19
20
21 unsigned int n_threads = std::thread::hardware_concurrency();
22
23 std::cout << "--- Hardware Concurrency Check ---" << std::endl;
24 if (n_threads == 0) {
25 std::cout << "Hardware concurrency not detectable. Defaulting to fallback." << std::endl;
26 } else {
27 std::cout << "Detected " << n_threads << " concurrent threads supported by hardware." << std::endl;
28 }
29
30 return 0;
31}