小编ben*_*ben的帖子

以可编程方式获取Windows上硬件线程数的可靠方法

我很难找到一种可靠的方法来获取Windows上的硬件线程数量.我在具有双CPU Intel Xeon E5-2699 v3 @ 2.30GHz的计算机上运行Windows 7 Professional SP1 64位,共计36个内核和72个线程.我已经尝试了不同的方法来获取内核的数量,我发现其中只有两个似乎在32位或64位进程中准确工作.这是我的结果:

+------------------------------------------------+----------------+----------------+
|                    Methods                     | 32-bit process | 64-bit process |
+------------------------------------------------+----------------+----------------+
| GetSystemInfo->dwNumberOfProcessors            |             32 |             36 |
| GetNativeSystemInfo->dwNumberOfProcessors      |             36 |             36 |
| GetLogicalProcessorInformation                 |             36 |             36 |
| GetProcessAffinityMask.processAffinityMask     |             32 |             32 |
| GetProcessAffinityMask.systemAffinityMask      |             32 |             32 |
| omp_get_num_procs                              |             32 |             36 |
| getenv("NUMBER_OF_PROCESSORS")                 |             36 |             36 |
| GetActiveProcessorCount(ALL_PROCESSOR_GROUPS)  |             64 |             72 | …

c++ windows winapi multithreading

8
推荐指数
1
解决办法
1152
查看次数

标签 统计

c++ ×1

multithreading ×1

winapi ×1

windows ×1