diff --git a/Include/Aurora/HWInfo/CpuInfo.hpp b/Include/Aurora/HWInfo/CpuInfo.hpp index 4f3fce33..a97d535e 100644 --- a/Include/Aurora/HWInfo/CpuInfo.hpp +++ b/Include/Aurora/HWInfo/CpuInfo.hpp @@ -16,16 +16,37 @@ namespace Aurora::HWInfo { Aurora::Build::EArchitecture cpuArch; + /// Total number of sockets reported by the hypervisor AuUInt8 uSocket; + + /// Total number of cores (Shared HV threads, e-cores, ...) AuUInt8 uCores; + + /// Total number of threads (hyperthreaded and e-cores) AuUInt8 uThreads; - AuList threadTopology; - AuList serverTopology; - CpuBitId maskECores; - CpuBitId entireCpu; + /// @deprecated small mask + AuList threadTopology; + + /// Each cores' thread mask no matter the socket + AuList coreTopology; + /// Each p-core's thread mask no matter the socket or cache inheritance + AuList pCoreTopology; + + /// Each e-core in a single CpuBitId mask + CpuBitId maskECores; + + /// Each p-core in a single CpuBitId mask + CpuBitId maskPCores; + + /// Each core in a single CpuBitIdMask + CpuBitId maskAllCores; + + /// @deprecated bool bMaskMTContig; + + /// @deprecated bool bMaskMTHalf; CpuId cpuId; diff --git a/Include/Aurora/Utility/RateLimiter.hpp b/Include/Aurora/Utility/RateLimiter.hpp index 3203040b..27166cb6 100644 --- a/Include/Aurora/Utility/RateLimiter.hpp +++ b/Include/Aurora/Utility/RateLimiter.hpp @@ -1,5 +1,5 @@ /*** - Copyright (C) 20212J Reece Wilson (a/k/a "Reece"). All rights reserved. + Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. File: RateLimiter.hpp Date: 2022-2-8 diff --git a/README.md b/README.md index 242f8dbb..a518863c 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ alloc, and str formatting objectives using known good industry standard librarie expected to be on the heavier side with optimal performance (incl toll for C++ pluses tradeoffs). -Runtime as of 2022-02-01 *with the entire wxWidgets toolkit and compression libraries* on Windows LTSC 2019: +Runtime as of 2022-02-01 *without the wxWidgets toolkit, with all compression libraries* on Windows LTSC 2019: DLL Disk: 4.2MB \ Size Of Image: 0x50B000 (5MB) \ @@ -69,6 +69,7 @@ Runtime as of 2022-02-01 *with the entire wxWidgets toolkit and compression libr ^1 ...on LTSC 2019. Modern Windows 10 and 11 will return the exact task manager value of 3,168K (3.1MB). + Defer to benchmarks ## Utilities diff --git a/Source/HWInfo/CpuInfo.NT.cpp b/Source/HWInfo/CpuInfo.NT.cpp index 32415412..16ce1ef0 100644 --- a/Source/HWInfo/CpuInfo.NT.cpp +++ b/Source/HWInfo/CpuInfo.NT.cpp @@ -76,7 +76,7 @@ namespace Aurora::HWInfo idx.server.push_back(cpuId); idx.low.push_back(id); idx.mask.Add(cpuId); - gCpuInfo.entireCpu.Add(cpuId); + gCpuInfo.maskAllCores.Add(cpuId); } for (const auto &[cpuId, coreIds] : cpuThreads) @@ -89,6 +89,11 @@ namespace Aurora::HWInfo { gCpuInfo.maskECores.Add(id); } + else + { + gCpuInfo.maskPCores.Add(id); + gCpuInfo.pCoreTopology.push_back(id); + } } for (const auto &id : coreIds.low) @@ -96,7 +101,7 @@ namespace Aurora::HWInfo shortMask |= AuUInt64(1) << AuUInt64(id); } - gCpuInfo.serverTopology.push_back(coreIds.mask); + gCpuInfo.coreTopology.push_back(coreIds.mask); gCpuInfo.threadTopology.push_back(shortMask); } @@ -153,6 +158,7 @@ namespace Aurora::HWInfo gCpuInfo.uThreads = 0; bool sparse = false; + bool hasHTCores = false; for (auto i = 0; i < length; i++) { if (sysinfo[i].Relationship == RelationProcessorCore) @@ -164,12 +170,11 @@ namespace Aurora::HWInfo CpuBitId serverId; serverId.lower = mask; - gCpuInfo.serverTopology.push_back(mask); + gCpuInfo.coreTopology.push_back(mask); - // TODO: fuck it, if some macro fuckery, use popcnt on x86 - // we just need to count the bits. first it was just two BitScanForwards. discontiguous cores fucked things up so now we have a loop just to count a few bits. int counter {}; unsigned long offset {}, tmp; + #if 0 while (offset != (sizeof(offset) * 8)) { // Count the index to a 1 @@ -185,6 +190,31 @@ namespace Aurora::HWInfo // Increment threads by the bits set in gCpuInfo.uThreads += tmp; } + #else + tmp = AuPopCnt(mask); + gCpuInfo.uThreads += tmp; + #endif + + hasHTCores |= (tmp == 2); + + if (hasHTCores && (tmp == 1)) + { + AuUInt8 idx {}; + if (serverId.CpuBitScanForward(idx, 0)) + { + gCpuInfo.maskECores.Add(idx); + } + } + else + { + AuUInt8 idx {}; + if (serverId.CpuBitScanForward(idx, 0)) + { + gCpuInfo.maskPCores.Add(idx); + } + gCpuInfo.pCoreTopology.push_back(mask); + } + } else if (sysinfo[i].Relationship == RelationProcessorPackage) { diff --git a/Source/HWInfo/CpuInfo.cpp b/Source/HWInfo/CpuInfo.cpp index 04150193..02b2dad0 100644 --- a/Source/HWInfo/CpuInfo.cpp +++ b/Source/HWInfo/CpuInfo.cpp @@ -48,38 +48,7 @@ namespace Aurora::HWInfo static void SetFakeTopologyIfMissing() { - if (gCpuInfo.threadTopology.size() || gCpuInfo.serverTopology.size()) - { - return; - } - - bool fakeMtHalf = (gCpuInfo.uThreads & 1) == 0; - gCpuInfo.bMaskMTHalf = fakeMtHalf; - - if (fakeMtHalf) - { - for (int i = 0; i < gCpuInfo.uThreads / 2; i++) - { - AuUInt64 shortMask {AuUInt64(1) << AuUInt64(i)}, shortMask2 {AuUInt64(1) << AuUInt64(i + gCpuInfo.uThreads / 2)}; - CpuBitId mask; - mask.lower = shortMask | shortMask2; - gCpuInfo.serverTopology.push_back(mask); - gCpuInfo.threadTopology.push_back(shortMask); - gCpuInfo.entireCpu.Add(mask); - } - } - else - { - for (int i = 0; i < gCpuInfo.uThreads; i++) - { - AuUInt64 shortMask {AuUInt64(1) << AuUInt64(i)}; - CpuBitId mask; - mask.lower = shortMask; - gCpuInfo.serverTopology.push_back(mask); - gCpuInfo.threadTopology.push_back(shortMask); - gCpuInfo.entireCpu.Add(mask); - } - } + // This stunk } void InitCpuInfo() diff --git a/Source/Loop/LoopQueue.NT.cpp b/Source/Loop/LoopQueue.NT.cpp index cd53cfbf..e8ff594f 100644 --- a/Source/Loop/LoopQueue.NT.cpp +++ b/Source/Loop/LoopQueue.NT.cpp @@ -116,7 +116,7 @@ namespace Aurora::Loop if (source->GetType() == ELoopSource::eSourceWin32) { - this->msgSource_ = {}; + this->msgSource_.reset(); this->msgCallbacks_ = {}; this->bIsWinLoop_ = false; return; @@ -144,6 +144,7 @@ namespace Aurora::Loop } handleIndex += delta; + if (sourceEx.source == source) { @@ -735,7 +736,7 @@ namespace Aurora::Loop if (source.source->GetType() == ELoopSource::eSourceWin32) { - this->msgSource_ = {}; + this->msgSource_.reset(); this->msgCallbacks_ = {}; this->bIsWinLoop_ = false; } @@ -847,7 +848,7 @@ namespace Aurora::Loop if (source.source->GetType() == ELoopSource::eSourceWin32) { - this->msgSource_ = {}; + this->msgSource_.reset(); this->msgCallbacks_ = {}; this->bIsWinLoop_ = false; } diff --git a/Source/Threading/Threads/OSThread.cpp b/Source/Threading/Threads/OSThread.cpp index 7cfdb401..c1b572c2 100644 --- a/Source/Threading/Threads/OSThread.cpp +++ b/Source/Threading/Threads/OSThread.cpp @@ -283,7 +283,7 @@ namespace Aurora::Threading::Threads if (mask == zero || mask == zero.Not()) { - this->mask_ = HWInfo::GetCPUInfo().entireCpu; + this->mask_ = HWInfo::GetCPUInfo().maskAllCores; } else {