hardware_info.hpp file
Physical vs logical CPU core detection.
Provides physical core counting for accurate thread pool sizing. On Linux, parses /sys/devices/system/cpu topology to distinguish physical cores from hyperthreads. Falls back to std::thread::hardware_concurrency() on other platforms or parse failure.
CPU quota
The process-global set_cpu_quota_pct() lets the user shrink the unit of "1 CPU" reported by physical_concurrency() once at startup. When a quota is set, every work-pool factory that multiplies the result by its own cpu_factor automatically gets a smaller slice of the host:
set_cpu_quota_pct(30) on a 9-physical-core box → physical_concurrency() = ceil(9 × 0.30) = 3
Pools with cpu_factor=2.0 then size to 6 threads instead of 18, pools with cpu_factor=4.0 size to 12 instead of 36, etc.
The detected hardware count is preserved via detected_physical_concurrency() so logs and SMT ratios remain meaningful.
Namespaces
- namespace gtopt