本人之前都是使用GetSystemInfo來獲取CPU邏輯核數,環境:win7 x64;2個物理CPU;每個CPU都是16個核;
使用GetSystemInfo獲取CPU邏輯核數dwNumberOfProcessors=32,是兩個物理CPU的總邏輯核數;
現于一臺新電腦上,仍使用GetSystemInfo發現,只獲取了一個CPU的邏輯核數;新電腦環境:win10 x64;2個物理CPU;每個CPU都是48個核;使用GetSystemInfo獲取CPU邏輯核數dwNumberOfProcessors=48,是一個物理CPU的邏輯核數;為什么不是96?請大神幫忙解釋下,感謝!
另附上GetSystemInfo獲取CPU邏輯核數的使用程式:
SYSTEM_INFO sys;
GetSystemInfo(&sys);
int num = 0;
num = sys.dwNumberOfProcessors;
uj5u.com熱心網友回復:
猜測是不是這個原因:你的32位程式跑在WOW64上,GetNativeSystemInfo試試To retrieve accurate information for an application running on WOW64, call the GetNativeSystemInfo function.
uj5u.com熱心網友回復:
GetLogicalProcessorInformationExuj5u.com熱心網友回復:
你好,我的程式是64位的,和系統一樣
uj5u.com熱心網友回復:
你好,能具體說一下嗎?不太懂這方面的內容
uj5u.com熱心網友回復:
https://stackoverflow.com/questions/41486106/trying-to-get-the-active-cores-confused-with-the-usage-of-getlogicalprocessorinfuj5u.com熱心網友回復:
std::thread::hardware_concurrency();這個試試行不行
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/8114.html
標籤:工具平臺和程序庫
