From 8b29e73f962d718bd1b3cf3794e5b0b47702b653 Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Mon, 4 Mar 2024 13:07:49 +0000 Subject: [PATCH] [*] Switch over to mapped cpuset ids as opposed to the ((groupIndex + 1ull) * 0x100ull) + logicalProcessorIndex approximation --- Include/Aurora/HWInfo/CpuBitId.NT.inl | 7 +++++++ Source/HWInfo/AuCpuInfo.NT.cpp | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/Include/Aurora/HWInfo/CpuBitId.NT.inl b/Include/Aurora/HWInfo/CpuBitId.NT.inl index c2d1ef24..cc1727fe 100644 --- a/Include/Aurora/HWInfo/CpuBitId.NT.inl +++ b/Include/Aurora/HWInfo/CpuBitId.NT.inl @@ -9,6 +9,8 @@ namespace Aurora::HWInfo { + extern AUKN_SYM AuUInt32 gWin32CPUSetLookupTable[512]; + AuList CpuBitId::ToCpuSets() const { AuList ret; @@ -16,10 +18,15 @@ namespace Aurora::HWInfo AuUInt8 index {}; while (CpuBitScanForward(index, index)) { + #if defined(AURORA_RUNTIME_USE_FAST_CPUSETS) unsigned long logicalProcessorIndex = index % 64; unsigned long groupIndex = index / 64; ret.push_back(((groupIndex + 1ull) * 0x100ull) + logicalProcessorIndex); index++; + #else + ret.push_back(gWin32CPUSetLookupTable[index]); + index++; + #endif } return ret; diff --git a/Source/HWInfo/AuCpuInfo.NT.cpp b/Source/HWInfo/AuCpuInfo.NT.cpp index f959705b..a535ecc4 100644 --- a/Source/HWInfo/AuCpuInfo.NT.cpp +++ b/Source/HWInfo/AuCpuInfo.NT.cpp @@ -16,6 +16,8 @@ namespace Aurora::HWInfo { + AUKN_SYM AuUInt32 gWin32CPUSetLookupTable[512] {}; + static bool SetWindows10CpuSetInfoSlow() { SYSTEM_CPU_SET_INFORMATION cpuSetInfo[128]; @@ -98,9 +100,15 @@ namespace Aurora::HWInfo AuUInt8 id = AuUInt8(cpuSetInfo[i].CpuSet.LogicalProcessorIndex /*no greater than 64*/ + (cpuSetInfo[i].CpuSet.Group * 64)); auto cpuId = CpuBitId(id); + #if defined(AURORA_RUNTIME_USE_FAST_CPUSETS) auto sets = cpuId.ToCpuSets(); SysAssert(sets.size() == 1); SysAssert(sets[0] == cpuSetInfo[i].CpuSet.Id); + #endif + + // Future proofing for later NT versions + SysAssert(id < AuArraySize(gWin32CPUSetLookupTable)); + gWin32CPUSetLookupTable[id] = cpuSetInfo[i].CpuSet.Id; idx.server.push_back(AuMakePair(cpuSetInfo[i].CpuSet.EfficiencyClass, cpuId)); idx.low.push_back(id);