CPUID on Intel i7 processors

Posted by StarPacker on Stack Overflow See other posts from Stack Overflow or by StarPacker
Published on 2009-10-29T23:33:40Z Indexed on 2010/04/03 9:03 UTC
Read the original article Hit count: 761

Filed under:
|

I'm having an issue with my CPUID-based code on newer i7-based machines. It is detecting the CPU as having a single core with 8 HT units instead of 4 cores each with 2 HT units.

I must be misinterpreting the results of the CPUID information coming back from the CPU, but I can't see how.

Basically, I iterate through each processor visible to Windows, set thread affinity to that thread and then make a sequence of CPUID calls.

args = new CPUID_Args();
args.eax = 1;
executeHandler(ref args);
if (0 != (args.edx & (0x1 << 28)))
{
  //If the 28th bit in EDX is flagged, this processor supports multiple logical processors per physical package
  // in this case bits 23:16 of EBX should give the count.
//** EBX here is 0x2100800
  logicalProcessorCount = (args.ebx & 0x00FF0000) >> 16;
//** this tells me there are 16 logical processors (wrong)
}
else
{ logicalProcessorCount = 1; }
apic = unchecked((byte)((0xFF000000 & args.ebx) >> 24));

if (maximumSupportedCPUID >= 4)
{
  args = new CPUID_Args();
  args.eax = 4;
  executeHandler(ref args);
//EAX now contains 0x1C004121
  coreCount = 1 + ((args.eax & 0xFC000000) >> 26);
//This calculates coreCount as 8
}
else
{ coreCount = 1; }

This sequence repeats for the remainder of the CPUs in the system.

Has anyone faced this before?

© Stack Overflow or respective owner

Related posts about cpu

Related posts about cpu-registers