[libcxx-commits] [libcxx] [libc++][Windows] Enable thread::hardware_concurrency to support more… (PR #168229)

Yexuan Xiao via libcxx-commits libcxx-commits at lists.llvm.org
Sat Nov 15 11:37:29 PST 2025


https://github.com/YexuanXiao created https://github.com/llvm/llvm-project/pull/168229

… than 64 processors

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.).

>From 0675385c2dcb3e00e9bd673c155e2e5e8a42fec7 Mon Sep 17 00:00:00 2001
From: Yexuan Xiao <bizwen at nykz.org>
Date: Sun, 16 Nov 2025 03:17:33 +0800
Subject: [PATCH] [libc++][Windows] Enable thread::hardware_concurrency to
 support more than 64 processors

---
 libcxx/src/thread.cpp | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libcxx/src/thread.cpp b/libcxx/src/thread.cpp
index 028d36e3bfb37..e494574ec21dd 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.



More information about the libcxx-commits mailing list