[llvm] bca1b8e - [SystemZ/ZOS] Implement computeHostNumPhysicalCores
Kai Nacke via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 12 05:33:05 PDT 2020
Author: Kai Nacke
Date: 2020-08-12T08:31:33-04:00
New Revision: bca1b8ed994336690db4775e67953aad533b0e31
URL: https://github.com/llvm/llvm-project/commit/bca1b8ed994336690db4775e67953aad533b0e31
DIFF: https://github.com/llvm/llvm-project/commit/bca1b8ed994336690db4775e67953aad533b0e31.diff
LOG: [SystemZ/ZOS] Implement computeHostNumPhysicalCores
On z/OS, the information is stored in the Common System Data Area
(CSD). It is the number of CPs allocated to the current LPAR.
Reviewers: aganea, hubert.reinterpertcast, MaskRay
Reviewed By: hubert.reinterpertcast
Differential Revision: https://reviews.llvm.org/D85531
Added:
Modified:
llvm/lib/Support/Host.cpp
llvm/unittests/Support/Host.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Support/Host.cpp b/llvm/lib/Support/Host.cpp
index 890b1178cbd0..bc06a7858f5b 100644
--- a/llvm/lib/Support/Host.cpp
+++ b/llvm/lib/Support/Host.cpp
@@ -1311,6 +1311,28 @@ int computeHostNumPhysicalCores() {
}
return count;
}
+#elif defined(__MVS__)
+int computeHostNumPhysicalCores() {
+ enum {
+ // Byte offset of the pointer to the Communications Vector Table (CVT) in
+ // the Prefixed Save Area (PSA). The table entry is a 31-bit pointer and
+ // will be zero-extended to uintptr_t.
+ FLCCVT = 16,
+ // Byte offset of the pointer to the Common System Data Area (CSD) in the
+ // CVT. The table entry is a 31-bit pointer and will be zero-extended to
+ // uintptr_t.
+ CVTCSD = 660,
+ // Byte offset to the number of live CPs in the LPAR, stored as a signed
+ // 32-bit value in the table.
+ CSD_NUMBER_ONLINE_STANDARD_CPS = 264,
+ };
+ char *PSA = 0;
+ char *CVT = reinterpret_cast<char *>(
+ static_cast<uintptr_t>(reinterpret_cast<unsigned int &>(PSA[FLCCVT])));
+ char *CSD = reinterpret_cast<char *>(
+ static_cast<uintptr_t>(reinterpret_cast<unsigned int &>(CVT[CVTCSD])));
+ return reinterpret_cast<int &>(CSD[CSD_NUMBER_ONLINE_STANDARD_CPS]);
+}
#elif defined(_WIN32) && LLVM_ENABLE_THREADS != 0
// Defined in llvm/lib/Support/Windows/Threading.inc
int computeHostNumPhysicalCores();
diff --git a/llvm/unittests/Support/Host.cpp b/llvm/unittests/Support/Host.cpp
index 41c7227dd94e..8029bb5830fc 100644
--- a/llvm/unittests/Support/Host.cpp
+++ b/llvm/unittests/Support/Host.cpp
@@ -36,13 +36,12 @@ class HostTest : public testing::Test {
protected:
bool isSupportedArchAndOS() {
// Initially this is only testing detection of the number of
- // physical cores, which is currently only supported/tested for
- // x86_64 Linux and Darwin.
+ // physical cores, which is currently only supported/tested on
+ // some systems.
return (Host.isOSWindows() && llvm_is_multithreaded()) ||
- (Host.isX86() &&
- (Host.isOSDarwin() || Host.getOS() == Triple::Linux)) ||
- (Host.getOS() == Triple::Linux &&
- (Host.isPPC64() || Host.isSystemZ()));
+ (Host.isX86() && (Host.isOSDarwin() || Host.isOSLinux())) ||
+ (Host.isPPC64() && Host.isOSLinux()) ||
+ (Host.isSystemZ() && (Host.isOSLinux() || Host.isOSzOS()));
}
HostTest() : Host(Triple::normalize(sys::getProcessTriple())) {}
More information about the llvm-commits
mailing list