Hi. What is the "bulletproof" way of getting number of processor cores for Xeons (especially old ones)?
I am asking because there is value called Maximum number of processor cores in physical processor package (CPUID EAX[31:26] ) which usually shows good value but for some reason for old processors it may be wrong. For example Intel Processor E7220, 2 cores per processor - for 4-way server it showed 4 cores per processor. Oddly /proc/cpuinfo shows good value.
Could someone help with that?
I use the Extended Topology Enumeration Leaf (0x0B) if it is supported:
- Invoking CPUID with EAX = 0x0B, ECX = 0x00 will yield NumThreadsPerCore in EBX[0:15].
- Invoking CPUID with EAX = 0x0B, ECX = 0x01 will yield NumThreads in EBX[0:15].
- NumCores = NumThreads / NumThreadsPerCore.
If the Extended Topology Enumeration Leaf (0x0B) is not supported, my fallback is to use the Deterministic Cache Parameters
- Invoking CPUID with EAX = 0x01, ECX = 0x00 will yield NumThreads in EBX[16:23].
- Invoking CPUID with EAX = 0x04, ECX = 0x00 will yield NumCoresLessOne in EAX[26:31].
- NumCores = NumCoresLessOne + 1.
- NumThreadsPerCore = NumThreads / NumCores.
Hope this helps,
No that's the two ways that were recommended to me by the processor folks (*many* moons ago). I was in the Desktop Boards org, so rarely had to deal with multiprocessor situations, however.
You could try posting this question in the Servers forum; you should see more Xeon-savvy folks over there...