diff options
| author | Yexuan Xiao <bizwen@nykz.org> | 2025-11-21 18:43:35 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-21 18:43:35 +0800 |
| commit | 5a3c2573a9644efe3384c4144b119148088b48ef (patch) | |
| tree | b0c024b54194bb6fe55a8688b48d7e97bcb711f2 /libcxx | |
| parent | bb1b82af395fe4a717c9b10948312e260b5ca666 (diff) | |
[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:
https://github.com/microsoft/STL/issues/5453,
https://github.com/microsoft/STL/pull/5459 (note: Reason STL uses the
more complex GetLogicalProcessorInformationEx:
https://github.com/microsoft/STL/pull/5459#discussion_r2072242241.).
Diffstat (limited to 'libcxx')
| -rw-r--r-- | libcxx/src/thread.cpp | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/libcxx/src/thread.cpp b/libcxx/src/thread.cpp index 028d36e3bfb3..e494574ec21d 100644 --- a/libcxx/src/thread.cpp +++ b/libcxx/src/thread.cpp @@ -74,9 +74,7 @@ unsigned thread::hardware_concurrency() noexcept { return 0; return static_cast<unsigned>(result); #elif defined(_LIBCPP_WIN32API) - SYSTEM_INFO info; - GetSystemInfo(&info); - return info.dwNumberOfProcessors; + return static_cast<unsigned>(GetActiveProcessorCount(ALL_PROCESSOR_GROUPS)); #else // defined(CTL_HW) && defined(HW_NCPU) // TODO: grovel through /proc or check cpuid on x86 and similar // instructions on other architectures. |
