Software Tuning, Performance Optimization & Platform Monitoring
Discussion regarding monitoring and software tuning methodologies, Performance Monitoring Unit (PMU) of Intel microprocessors, and platform updating.

Sandybridge processors report incorrect core number?

Liam_McSherry
Beginner
945 Views

Whilst developing some software that reports information about x86 processors, I noticed something strange: Sandybridge processors report an incorrect core number.

This is how I'm retrieving the core number (pseudocode):

Move 0x00000004 into EAX

Move 0x00000000 into ECX

Call CPUID

Logical AND on bits EAX[31:26]

Shift EAX right by 26

Increase value of EAX by 1

On my primary test platform, an Intel Pentium T4500 (Penryn), it reports the core number correctly, as shown below:

However, on a separate machine with an Intel Core i5 2500K, it reports the core number incorrectly, as shown below:

Does anyone know why it is reporting double the number of cores it should? Both programs are running exactly the same code (and it isn't Windows 8, because I've tested on Windows 7 with a 2500K).

0 Kudos
7 Replies
Bernard
Valued Contributor I
945 Views
Maybe logical cores are also counted?
0 Kudos
Liam_McSherry
Beginner
945 Views
iliyapolak wrote:

Maybe logical cores are also counted?

According to the reference I'm using, the logical processor count is available through a different value of EAX when calling CPUID (0x00000001 instead of 0x00000004).
0 Kudos
Bernard
Valued Contributor I
945 Views
Can you use some tool to check for the correct number of cores? I would often use windbg and issue !cpuid command. Did you check your program with some kind of disassembler there is miniscule possibility of the code beign compiled wrongly.Run your tool also under debugger in single-step mode and observe what values are passed to/from registers and/or stack.
0 Kudos
Liam_McSherry
Beginner
945 Views
iliyapolak wrote:

Can you use some tool to check for the correct number of cores?
I would often use windbg and issue !cpuid command.
Did you check your program with some kind of disassembler there is miniscule possibility of the code beign compiled wrongly.Run your tool also under debugger in single-step mode and observe what values are passed to/from registers and/or stack.

I doubt it's being compiled wrongly as the same build of the program works on an AMD Athlon and my Pentium, but not any processors that are Sandybridge (I've tested on both an i5-2320 and two i5-2500Ks). The correct number of cores on a 2500K is 4.
0 Kudos
Bernard
Valued Contributor I
945 Views
>>>but not any processors that are Sandybridge (I've tested on both an i5-2320 and two i5-2500Ks). The correct number of cores on a 2500K i>>> Could that be some bug(error) at the microcode level, possibly wrong decoding and interpretation of the cpuid arguments.
0 Kudos
Patrick_F_Intel1
Employee
945 Views
The cpuid info doesn't report the current number of cores. The current cpuid appnote says the field reports "Maximum number of processor cores". This is not the same as the current number of cores. You can look at http://software.intel.com/en-us/articles/intel-64-architecture-processor-topology-enumeration for the method of figuring the number of cores. Or use what the OS reports. Pat
0 Kudos
Liam_McSherry
Beginner
945 Views
Patrick Fay (Intel) wrote:

The cpuid info doesn't report the current number of cores.
The current cpuid appnote says the field reports "Maximum number of processor cores".
This is not the same as the current number of cores.
You can look at http://software.intel.com/en-us/articles/intel-64-architecture-processor... for the method of figuring the number of cores.
Or use what the OS reports.
Pat

Ah, I haven't been using Intel architecture references. Thanks.
0 Kudos
Reply