Skip to content

hw_config: fix Windows CPU detection #521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 23, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/shims/hw_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ _dispatch_hw_get_config(_dispatch_hw_config_t c)
PSYSTEM_LOGICAL_PROCESSOR_INFORMATION slpiInfo = NULL;
PSYSTEM_LOGICAL_PROCESSOR_INFORMATION slpiCurrent = NULL;
DWORD dwProcessorLogicalCount = 0;
DWORD dwProcessorPackageCount = 0;
DWORD dwProcessorCoreCount = 0;
DWORD dwProcessorPhysicalCount = 0;
DWORD dwSize = 0;

while (true) {
Expand Down Expand Up @@ -154,12 +153,10 @@ _dispatch_hw_get_config(_dispatch_hw_config_t c)
slpiCurrent++, dwSize -= sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION)) {
switch (slpiCurrent->Relationship) {
case RelationProcessorCore:
++dwProcessorCoreCount;
++dwProcessorPhysicalCount;
dwProcessorLogicalCount += __popcnt64(slpiCurrent->ProcessorMask);
break;
case RelationProcessorPackage:
++dwProcessorPackageCount;
break;
case RelationNumaNode:
case RelationCache:
case RelationGroup:
Expand All @@ -172,11 +169,10 @@ _dispatch_hw_get_config(_dispatch_hw_config_t c)

switch (c) {
case _dispatch_hw_config_logical_cpus:
case _dispatch_hw_config_active_cpus:
return dwProcessorLogicalCount;
case _dispatch_hw_config_physical_cpus:
return dwProcessorPackageCount;
case _dispatch_hw_config_active_cpus:
return dwProcessorCoreCount;
return dwProcessorPhysicalCount;
}
#else
const char *name = NULL;
Expand Down