[llvm] 2cac95b - [AIX][PowerPC] Teach the Threading Library About the Number of Physical Cores on AIX (#67683)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 29 07:23:24 PDT 2023
Author: Qiongsi Wu
Date: 2023-09-29T10:23:20-04:00
New Revision: 2cac95ba2bd91adb4dad552993d589770ec6996d
URL: https://github.com/llvm/llvm-project/commit/2cac95ba2bd91adb4dad552993d589770ec6996d
DIFF: https://github.com/llvm/llvm-project/commit/2cac95ba2bd91adb4dad552993d589770ec6996d.diff
LOG: [AIX][PowerPC] Teach the Threading Library About the Number of Physical Cores on AIX (#67683)
The threading library does not recognize AIX and always returns `-1` for
number of physical cores on AIX. This PR teaches the library to
recognize AIX and obtain the correct value for the number of physical
cores.
Added:
Modified:
llvm/lib/Support/CMakeLists.txt
llvm/lib/Support/Unix/Threading.inc
llvm/unittests/Support/Threading.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt
index 54baf159a86877c..b96d62c7a6224d6 100644
--- a/llvm/lib/Support/CMakeLists.txt
+++ b/llvm/lib/Support/CMakeLists.txt
@@ -118,6 +118,15 @@ if(LLVM_INTEGRATED_CRT_ALLOC)
endif()
endif()
+# FIXME: We are currently guarding AIX headers with _XOPEN_SOURCE=700.
+# See llvm/CMakeLists.txt. However, we need _SC_NPROCESSORS_ONLN in
+# unistd.h and it is guarded by _ALL_SOURCE, so we remove the _XOPEN_SOURCE
+# guard here. We should remove the guards all together once AIX cleans up
+# the system headers.
+if (UNIX AND ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+ remove_definitions("-D_XOPEN_SOURCE=700")
+endif()
+
add_subdirectory(BLAKE3)
add_llvm_component_library(LLVMSupport
diff --git a/llvm/lib/Support/Unix/Threading.inc b/llvm/lib/Support/Unix/Threading.inc
index 819748db4ec21e8..55e7dcfa4678cf1 100644
--- a/llvm/lib/Support/Unix/Threading.inc
+++ b/llvm/lib/Support/Unix/Threading.inc
@@ -371,7 +371,7 @@ static int computeHostNumPhysicalCores() {
}
return CPU_COUNT(&Enabled);
}
-#elif defined(__linux__) && defined(__s390x__)
+#elif (defined(__linux__) && defined(__s390x__)) || defined(_AIX)
static int computeHostNumPhysicalCores() {
return sysconf(_SC_NPROCESSORS_ONLN);
}
diff --git a/llvm/unittests/Support/Threading.cpp b/llvm/unittests/Support/Threading.cpp
index b5eff6f6f14fba6..7fd8b1cfe3a5b9c 100644
--- a/llvm/unittests/Support/Threading.cpp
+++ b/llvm/unittests/Support/Threading.cpp
@@ -29,7 +29,7 @@ static bool isThreadingSupportedArchAndOS() {
return (Host.isOSWindows() && llvm_is_multithreaded()) || Host.isOSDarwin() ||
(Host.isX86() && Host.isOSLinux()) ||
(Host.isOSLinux() && !Host.isAndroid()) ||
- (Host.isSystemZ() && Host.isOSzOS());
+ (Host.isSystemZ() && Host.isOSzOS()) || Host.isOSAIX();
#else
return false;
#endif
More information about the llvm-commits
mailing list