How can I get the number of processors in the system, when there are more than 64?
A customer noted that the way their program obtains the number of processors is by calling
GetSystemInfo and looking at the
dwNumberOfProcessors. However, the documentation notes that this gives the number of processors in the current processor group, and that can be less than the total number of processors.
For example, when they checked the
dwNumberOfProcessors on a system with 80 processors (lucky them), they found that it reported only 40 processors.
How can they get the total number of processors across all processor groups?
The easy way is to call
GetActiveProcessorCount with the
GROUPS parameter. This counts up all processors across all groups.
The hard way is to call
GetLogicalProcessorInformationEx and ask for
RelationGroup. Then go through all the active groups and add up all of the
ActiveProcessorCounts. This is more work, but you also get to see the distribution of the processors among the groups, if that’s something you’re interested in.