How can I get the number of processors in the system, when there are more than 64?

Raymond Chen

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­Counts. 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.

8 comments

Discussion is closed. Login to edit/delete existing comments.

  • David Bry 0

    “64 processors ought to be enough for anybody.”

    • Jan RingoÅ¡ 0

      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.

  • Chris Crowther 0

    You can get 96 vCPUs using an Azure VM…although I suspect it would blow my monthly MSDN Azure budget instantly.

  • Mystery Man 0

    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.

  • Mystery Man 0

    By the way, happy Windows 95 anniversary, Mr. Chen. 😊

    I miss the engineers behind it.

  • Thiago Macieira 0

    > 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).

  • Campbell Kerr 0

    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!

    • Petr Kadlec 0

      You need to right-click the graph and choose Change graph to \ Logical processors.

Feedback usabilla icon