Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get correct number of logical processors

In Delphi, we need to know the number of CPUs for parallelization. Until now, we have used the GetNativeSystemInfo() function, which has worked fine, also with servers with hyperthreading.

But now, we have a server (Intel Xeon Gold 6230) with 40 physical processors and 80 logical processors with hyperthreading, and GetNativeSystemInfo() only shows 40 CPUs.

We made a small test program that uses 3 calls:

  1. GetNativeSystemInfo()

  2. GetLogicalProcessorInformation() (code from How to detect number of logical and physical processors efficiently?)

  3. And looking into the Registry for number of CPUs:

    Computer\HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor

For all of our servers, these 3 calls give the same number of CPUs:

image

But for the Intel Xeon, only the Registry gives us the 80 CPUs:

image

Does anybody know why it is not working for the Intel server, or know a way to be sure to get the max number of CPUs?

like image 970
Toke Avatar asked Dec 18 '22 16:12

Toke


1 Answers

In GetLogicalProcessorInformation documentation I found this part:

On systems with more than 64 logical processors, the GetLogicalProcessorInformation function retrieves logical processor information about processors in the processor group to which the calling thread is currently assigned. Use the GetLogicalProcessorInformationEx function to retrieve information about processors in all processor groups on the system.

So try using GetLogicalProcessorInformationEx.

like image 176
Fabrizio Avatar answered Dec 24 '22 02:12

Fabrizio