[*] CpuInfo (and others) refactor
This commit is contained in:
parent
57b4fe202a
commit
8b4bdbd04b
@ -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<AuInt64> threadTopology;
|
||||
AuList<CpuBitId> serverTopology;
|
||||
CpuBitId maskECores;
|
||||
CpuBitId entireCpu;
|
||||
/// @deprecated small mask
|
||||
AuList<AuInt64> threadTopology;
|
||||
|
||||
/// Each cores' thread mask no matter the socket
|
||||
AuList<CpuBitId> coreTopology;
|
||||
|
||||
/// Each p-core's thread mask no matter the socket or cache inheritance
|
||||
AuList<CpuBitId> 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;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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()
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user