Boost.Thread 1.56.0では、従来からあるシステムの論理プロセッサコア数取得関数に加えて、物理プロセッサコア数取得関数が追加された。
#include <boost/thread.hpp> int vnum = boost::thread::hardware_concurrency(); // 論理コア数 int pnum = boost::thread::physical_concurrency(); // 物理コア数 // 例:論理8コア/物理4コア環境ならば vnum==8 && pnum==4
unsigned hardware_concurrency() noexecpt;
Returns:
The number of hardware threads available on the current system (e.g. number of CPUs or cores or hyperthreading units), or 0 if this information is not available.Boost.Thread - Thread Management
unsigned physical_concurrency() noexecpt;
Returns:
The number of physical cores available on the current system. In contrast tohardware_concurrency()
it does not return the number of virtual cores, but it counts only physical cores.
関連URL
- cppreference thread::hardware_concurrency
- cpprefjp thread::hardware_concurrency