Sandybridge processors report incorrect core number?

Sandybridge processors report incorrect core number?

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

8 帖子 / 0 全新
最新文章
如需更全面地了解编译器优化,请参阅优化注意事项

Maybe logical cores are also counted?

引文:

iliyapolak 写道:

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

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.

引文:

iliyapolak 写道:

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.

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

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

引文:

Patrick Fay (Intel) 写道:

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.

发表评论

登录添加评论。还不是成员?立即加入