[*] Switch over to mapped cpuset ids as opposed to the ((groupIndex + 1ull) * 0x100ull) + logicalProcessorIndex approximation

This commit is contained in:
Reece Wilson 2024-03-04 13:07:49 +00:00
parent 2163a58892
commit 8b29e73f96
2 changed files with 15 additions and 0 deletions

View File

@ -9,6 +9,8 @@
namespace Aurora::HWInfo
{
extern AUKN_SYM AuUInt32 gWin32CPUSetLookupTable[512];
AuList<unsigned long> CpuBitId::ToCpuSets() const
{
AuList<unsigned long> 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;

View File

@ -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);