Skip to content

Commit

Permalink
Attempt at fix physical core count being zero
Browse files Browse the repository at this point in the history
Because P4 has CPUID.04h.EAX[31:26] unset, it would set that as physical core count

Assuming P4 is in the legacy camp, if mids is set to one (because of value+1), assume legacy calculations.

Don't have a Pentium so I can't test this, and I don't have a Pentium D so calculations might be thrown off
  • Loading branch information
dd86k committed Jan 17, 2025
1 parent 4cbbd6b commit b7a4597
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/ddcpuid.d
Original file line number Diff line number Diff line change
Expand Up @@ -1999,7 +1999,7 @@ L_CACHE_INTEL_4H:
ca.level = regs.al >> 5;
ca.lineSize = (regs.bx & 0xfff) + 1; // bits 11-0
ca.partitions = ((regs.ebx >> 12) & 0x3ff) + 1; // bits 21-12
ca.ways = ((regs.ebx >> 22) + 1); // bits 31-22
ca.ways = (regs.ebx >> 22) + 1; // bits 31-22
ca.sets = regs.ecx + 1;
if (regs.eax & BIT!(8)) ca.features = 1;
if (regs.eax & BIT!(9)) ca.features |= BIT!(1);
Expand All @@ -2011,8 +2011,17 @@ L_CACHE_INTEL_4H:
mids = (regs.eax >> 26) + 1; // EAX[31:26]

if (cpu.logicalCores == 0) with (cpu) { // skip if already populated
logicalCores = mids;
physicalCores = cpu.htt ? mids >> 1 : mids;
// Pentium 4 524 (with HTT=1) will have mids=1
// mids >> 1 (/2) = 0 phys cores
// so assuming mids=1 is legacy
if (mids == 1) {
physicalCores = 1;
// htt=1+1 -> 2 threads, htt=0+1 -> 1 thread
logicalCores = cpu.htt + 1;
} else {
logicalCores = mids;
physicalCores = cpu.htt ? mids >> 1 : mids;
}
}

crshrd = (((regs.eax >> 14) & 2047) + 1); // EAX[25:14]
Expand Down

0 comments on commit b7a4597

Please sign in to comment.