A customer noted that the way their program obtains the number of processors is by calling GetÂSystemÂInfo
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 GetÂActiveÂProcessorÂCount
with the ALL_
PROCESSOR_
GROUPS
parameter. This counts up all processors across all groups.
The hard way is to call GetÂLogicalÂProcessorÂInformationÂEx
and ask for RelationÂGroup
. Then go through all the active groups and add up all of the ActiveÂProcessorÂCount
s. 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.
Can understand why taskmgr these days only shows a single CPU graph, instead of 1 graph per CPU. I remember Windows servers with 16 or 32 cores trying to display each core in taskmgr, was fun to look at I guess!
You need to right-click the graph and choose Change graph to \ Logical processors.
> The hard way is to call GetÂLogicalÂProcessorÂInformationÂEx and ask for RelationÂGroup.
Note it has to be GetÂLogicalÂProcessorÂInformationÂEx, not GetÂLogicalÂProcessorÂInformationÂ, which is slightly easier to parse. The latter has the same limitation and only reports the processors in the current processor group. On Raymond's example machine with 80 logical processors, GetÂLogicalÂProcessorÂInformation would report a single "RelationGroup" with 40 logical processors in them (usually 20 cores with 2 threads each).
By the way, happy Windows 95 anniversary, Mr. Chen. 😊
I miss the engineers behind it.
How lucky to run into this post. I was trying to find a way to get the number of available CPU cores in Node.js. Lately, I’ve been having some extra time, so I thought why not get a copy of e-Mage’s source code and alter it so that it processes its image list one per CPU core at a time.
You can get 96 vCPUs using an Azure VM…although I suspect it would blow my monthly MSDN Azure budget instantly.
“64 processors ought to be enough for anybody.”
In times, where only the most expensive machines had 4 cores, it seemed like a good idea to use bitmask for logical processor (HW thread) affinities and everything.