[*] CpuInfo (and others) refactor
This commit is contained in:
parent
57b4fe202a
commit
8b4bdbd04b
@ -16,16 +16,37 @@ namespace Aurora::HWInfo
|
|||||||
{
|
{
|
||||||
Aurora::Build::EArchitecture cpuArch;
|
Aurora::Build::EArchitecture cpuArch;
|
||||||
|
|
||||||
|
/// Total number of sockets reported by the hypervisor
|
||||||
AuUInt8 uSocket;
|
AuUInt8 uSocket;
|
||||||
|
|
||||||
|
/// Total number of cores (Shared HV threads, e-cores, ...)
|
||||||
AuUInt8 uCores;
|
AuUInt8 uCores;
|
||||||
|
|
||||||
|
/// Total number of threads (hyperthreaded and e-cores)
|
||||||
AuUInt8 uThreads;
|
AuUInt8 uThreads;
|
||||||
|
|
||||||
|
/// @deprecated small mask
|
||||||
AuList<AuInt64> threadTopology;
|
AuList<AuInt64> threadTopology;
|
||||||
AuList<CpuBitId> serverTopology;
|
|
||||||
CpuBitId maskECores;
|
|
||||||
CpuBitId entireCpu;
|
|
||||||
|
|
||||||
|
/// 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;
|
bool bMaskMTContig;
|
||||||
|
|
||||||
|
/// @deprecated
|
||||||
bool bMaskMTHalf;
|
bool bMaskMTHalf;
|
||||||
|
|
||||||
CpuId cpuId;
|
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
|
File: RateLimiter.hpp
|
||||||
Date: 2022-2-8
|
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).
|
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 \
|
DLL Disk: 4.2MB \
|
||||||
Size Of Image: 0x50B000 (5MB) \
|
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).
|
^1 ...on LTSC 2019. Modern Windows 10 and 11 will return the exact task manager value of 3,168K (3.1MB).
|
||||||
|
|
||||||
|
|
||||||
Defer to benchmarks
|
Defer to benchmarks
|
||||||
|
|
||||||
## Utilities
|
## Utilities
|
||||||
|
@ -76,7 +76,7 @@ namespace Aurora::HWInfo
|
|||||||
idx.server.push_back(cpuId);
|
idx.server.push_back(cpuId);
|
||||||
idx.low.push_back(id);
|
idx.low.push_back(id);
|
||||||
idx.mask.Add(cpuId);
|
idx.mask.Add(cpuId);
|
||||||
gCpuInfo.entireCpu.Add(cpuId);
|
gCpuInfo.maskAllCores.Add(cpuId);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto &[cpuId, coreIds] : cpuThreads)
|
for (const auto &[cpuId, coreIds] : cpuThreads)
|
||||||
@ -89,6 +89,11 @@ namespace Aurora::HWInfo
|
|||||||
{
|
{
|
||||||
gCpuInfo.maskECores.Add(id);
|
gCpuInfo.maskECores.Add(id);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gCpuInfo.maskPCores.Add(id);
|
||||||
|
gCpuInfo.pCoreTopology.push_back(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto &id : coreIds.low)
|
for (const auto &id : coreIds.low)
|
||||||
@ -96,7 +101,7 @@ namespace Aurora::HWInfo
|
|||||||
shortMask |= AuUInt64(1) << AuUInt64(id);
|
shortMask |= AuUInt64(1) << AuUInt64(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
gCpuInfo.serverTopology.push_back(coreIds.mask);
|
gCpuInfo.coreTopology.push_back(coreIds.mask);
|
||||||
gCpuInfo.threadTopology.push_back(shortMask);
|
gCpuInfo.threadTopology.push_back(shortMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,6 +158,7 @@ namespace Aurora::HWInfo
|
|||||||
gCpuInfo.uThreads = 0;
|
gCpuInfo.uThreads = 0;
|
||||||
|
|
||||||
bool sparse = false;
|
bool sparse = false;
|
||||||
|
bool hasHTCores = false;
|
||||||
for (auto i = 0; i < length; i++)
|
for (auto i = 0; i < length; i++)
|
||||||
{
|
{
|
||||||
if (sysinfo[i].Relationship == RelationProcessorCore)
|
if (sysinfo[i].Relationship == RelationProcessorCore)
|
||||||
@ -164,12 +170,11 @@ namespace Aurora::HWInfo
|
|||||||
|
|
||||||
CpuBitId serverId;
|
CpuBitId serverId;
|
||||||
serverId.lower = mask;
|
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 {};
|
int counter {};
|
||||||
unsigned long offset {}, tmp;
|
unsigned long offset {}, tmp;
|
||||||
|
#if 0
|
||||||
while (offset != (sizeof(offset) * 8))
|
while (offset != (sizeof(offset) * 8))
|
||||||
{
|
{
|
||||||
// Count the index to a 1
|
// Count the index to a 1
|
||||||
@ -185,6 +190,31 @@ namespace Aurora::HWInfo
|
|||||||
// Increment threads by the bits set in
|
// Increment threads by the bits set in
|
||||||
gCpuInfo.uThreads += tmp;
|
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)
|
else if (sysinfo[i].Relationship == RelationProcessorPackage)
|
||||||
{
|
{
|
||||||
|
@ -48,38 +48,7 @@ namespace Aurora::HWInfo
|
|||||||
|
|
||||||
static void SetFakeTopologyIfMissing()
|
static void SetFakeTopologyIfMissing()
|
||||||
{
|
{
|
||||||
if (gCpuInfo.threadTopology.size() || gCpuInfo.serverTopology.size())
|
// This stunk
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitCpuInfo()
|
void InitCpuInfo()
|
||||||
|
@ -116,7 +116,7 @@ namespace Aurora::Loop
|
|||||||
|
|
||||||
if (source->GetType() == ELoopSource::eSourceWin32)
|
if (source->GetType() == ELoopSource::eSourceWin32)
|
||||||
{
|
{
|
||||||
this->msgSource_ = {};
|
this->msgSource_.reset();
|
||||||
this->msgCallbacks_ = {};
|
this->msgCallbacks_ = {};
|
||||||
this->bIsWinLoop_ = false;
|
this->bIsWinLoop_ = false;
|
||||||
return;
|
return;
|
||||||
@ -145,6 +145,7 @@ namespace Aurora::Loop
|
|||||||
|
|
||||||
handleIndex += delta;
|
handleIndex += delta;
|
||||||
|
|
||||||
|
|
||||||
if (sourceEx.source == source)
|
if (sourceEx.source == source)
|
||||||
{
|
{
|
||||||
AuRemoveRange(this->handleArray_, lsStartIndex, delta);
|
AuRemoveRange(this->handleArray_, lsStartIndex, delta);
|
||||||
@ -735,7 +736,7 @@ namespace Aurora::Loop
|
|||||||
|
|
||||||
if (source.source->GetType() == ELoopSource::eSourceWin32)
|
if (source.source->GetType() == ELoopSource::eSourceWin32)
|
||||||
{
|
{
|
||||||
this->msgSource_ = {};
|
this->msgSource_.reset();
|
||||||
this->msgCallbacks_ = {};
|
this->msgCallbacks_ = {};
|
||||||
this->bIsWinLoop_ = false;
|
this->bIsWinLoop_ = false;
|
||||||
}
|
}
|
||||||
@ -847,7 +848,7 @@ namespace Aurora::Loop
|
|||||||
|
|
||||||
if (source.source->GetType() == ELoopSource::eSourceWin32)
|
if (source.source->GetType() == ELoopSource::eSourceWin32)
|
||||||
{
|
{
|
||||||
this->msgSource_ = {};
|
this->msgSource_.reset();
|
||||||
this->msgCallbacks_ = {};
|
this->msgCallbacks_ = {};
|
||||||
this->bIsWinLoop_ = false;
|
this->bIsWinLoop_ = false;
|
||||||
}
|
}
|
||||||
|
@ -283,7 +283,7 @@ namespace Aurora::Threading::Threads
|
|||||||
if (mask == zero ||
|
if (mask == zero ||
|
||||||
mask == zero.Not())
|
mask == zero.Not())
|
||||||
{
|
{
|
||||||
this->mask_ = HWInfo::GetCPUInfo().entireCpu;
|
this->mask_ = HWInfo::GetCPUInfo().maskAllCores;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user