[llvm] [AIX][PowerPC] Teach the Threading Library About the Number of Physical Cores on AIX (PR #67683)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 28 07:17:30 PDT 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-support
<details>
<summary>Changes</summary>
The threading library does not recognize AIX and always returns -1 for number of physical cores. This PR teaches the library to recognize AIX and obtain the correct value for the number of physical cores.
---
Full diff: https://github.com/llvm/llvm-project/pull/67683.diff
2 Files Affected:
- (modified) llvm/lib/Support/Unix/Threading.inc (+6)
- (modified) llvm/unittests/Support/Threading.cpp (+1-1)
``````````diff
diff --git a/llvm/lib/Support/Unix/Threading.inc b/llvm/lib/Support/Unix/Threading.inc
index 819748db4ec21e8..1d5f01264784d4e 100644
--- a/llvm/lib/Support/Unix/Threading.inc
+++ b/llvm/lib/Support/Unix/Threading.inc
@@ -55,6 +55,10 @@
#include <unistd.h> // For syscall()
#endif
+#if defined(_AIX)
+#include <sys/systemcfg.h>
+#endif
+
namespace llvm {
pthread_t
llvm_execute_on_thread_impl(void *(*ThreadFunc)(void *), void *Arg,
@@ -432,6 +436,8 @@ static int computeHostNumPhysicalCores() {
static_cast<uintptr_t>(reinterpret_cast<unsigned int &>(CVT[CVTCSD])));
return reinterpret_cast<int &>(CSD[CSD_NUMBER_ONLINE_STANDARD_CPS]);
}
+#elif defined(_AIX)
+static int computeHostNumPhysicalCores() { return _system_configuration.ncpus; }
#else
// On other systems, return -1 to indicate unknown.
static int computeHostNumPhysicalCores() { return -1; }
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/67683
More information about the llvm-commits
mailing list