我在新款i7机器上,使用基于CPUID的代码出现了问题。它将CPU检测为具有8个超线程单元的单核心,而不是4个核心,每个核心都有2个超线程单元。
我一定是误解了来自CPU的CPUID信息结果,但我不知道哪里出了问题。
基本上,我遍历每个可见于Windows的处理器,将线程关联到该线程,然后进行一系列的CPUID调用。
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; }
这个序列会重复到系统中的其余CPU。
有人以前遇到过这种情况吗?