[*] Count discontiguous bits in the win32 processor map
This commit is contained in:
parent
5e0cc1ccfa
commit
586ec565e1
@ -435,11 +435,22 @@ namespace Aurora::HWInfo
|
|||||||
if (sysinfo[i].Relationship == RelationProcessorCore)
|
if (sysinfo[i].Relationship == RelationProcessorCore)
|
||||||
{
|
{
|
||||||
gCpuInfo.cores++;
|
gCpuInfo.cores++;
|
||||||
|
|
||||||
auto mask = sysinfo[i].ProcessorMask;
|
auto mask = sysinfo[i].ProcessorMask;
|
||||||
unsigned long offset, count;
|
unsigned long offset {}, tmp;
|
||||||
BitScanForward(&offset, mask);
|
while (offset != (sizeof(offset) * 8 - 1))
|
||||||
BitScanForward(&count, ~(mask >> offset));
|
{
|
||||||
gCpuInfo.threads += count;
|
// Count the index to a 1
|
||||||
|
if (BitScanForward(&tmp, mask >> offset) == 0) break; // mask was zero, end of scan
|
||||||
|
offset += tmp;
|
||||||
|
|
||||||
|
// Count the 1's by inverting the bitmap and counting to 1
|
||||||
|
BitScanForward(&tmp, ~(mask >> offset));
|
||||||
|
offset += tmp;
|
||||||
|
|
||||||
|
// Increment threads by the bits set in
|
||||||
|
gCpuInfo.threads += tmp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (sysinfo[i].Relationship == RelationProcessorPackage)
|
else if (sysinfo[i].Relationship == RelationProcessorPackage)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user