[llvm] [AIX][PowerPC] Teach the Threading Library About the Number of Physical Cores on AIX (PR #67683)
Qiongsi Wu via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 28 07:16:23 PDT 2023
https://github.com/qiongsiwu created https://github.com/llvm/llvm-project/pull/67683
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.
>From a384b08716cc9a37b3fe646ee4ff9ac3f6ad9b63 Mon Sep 17 00:00:00 2001
From: Qiongsi Wu <qwu at ibm.com>
Date: Thu, 28 Sep 2023 09:39:57 -0400
Subject: [PATCH] Teach the threading library about number of physical cores on
AIX
---
llvm/lib/Support/Unix/Threading.inc | 6 ++++++
llvm/unittests/Support/Threading.cpp | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
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
More information about the llvm-commits
mailing list