Skip to content

Commit 5a3c257

Browse files
authored
[libc++][Windows] Enable thread::hardware_concurrency to support more than 64 processors (#168229)
Starting with Windows 11, processes can utilize more than 64 processors by default, but GetSystemInfo can only report a maximum of 64. Starting with Windows Vista, GetActiveProcessorCount accurately retrieves the total number of processors on the current system. I’ve implemented similar improvements to Microsoft STL. The following links contain additional background information: microsoft/STL#5453, microsoft/STL#5459 (note: Reason STL uses the more complex GetLogicalProcessorInformationEx: microsoft/STL#5459 (comment).).
1 parent bb1b82a commit 5a3c257

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

libcxx/src/thread.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ unsigned thread::hardware_concurrency() noexcept {
7474
return 0;
7575
return static_cast<unsigned>(result);
7676
#elif defined(_LIBCPP_WIN32API)
77-
SYSTEM_INFO info;
78-
GetSystemInfo(&info);
79-
return info.dwNumberOfProcessors;
77+
return static_cast<unsigned>(GetActiveProcessorCount(ALL_PROCESSOR_GROUPS));
8078
#else // defined(CTL_HW) && defined(HW_NCPU)
8179
// TODO: grovel through /proc or check cpuid on x86 and similar
8280
// instructions on other architectures.

0 commit comments

Comments
 (0)