[PATCH] D85531: [SystemZ/ZOS] Add support for getHostNumPhysicalCores()
Kai Nacke via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 7 08:45:47 PDT 2020
Kai created this revision.
Kai added reviewers: uweigand, hubert.reinterpretcast, yusra.syeda, kbarton, abhina.sreeskantharajan, MaskRay, aganea.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
Kai requested review of this revision.
The information about the CPs online in an LPAR is stored in a control block.
The code navigates to the right control block and returns the number.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D85531
Files:
llvm/lib/Support/Host.cpp
llvm/unittests/Support/Host.cpp
Index: llvm/unittests/Support/Host.cpp
===================================================================
--- llvm/unittests/Support/Host.cpp
+++ llvm/unittests/Support/Host.cpp
@@ -37,12 +37,13 @@
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.
+ // x86_64 Linux and Darwin and for z/OS.
return (Host.isOSWindows() && llvm_is_multithreaded()) ||
(Host.isX86() &&
(Host.isOSDarwin() || Host.getOS() == Triple::Linux)) ||
(Host.getOS() == Triple::Linux &&
- (Host.isPPC64() || Host.isSystemZ()));
+ (Host.isPPC64() || Host.isSystemZ()) ||
+ (Host.isSystemZ() && Host.isOSzOS());
}
HostTest() : Host(Triple::normalize(sys::getProcessTriple())) {}
Index: llvm/lib/Support/Host.cpp
===================================================================
--- llvm/lib/Support/Host.cpp
+++ llvm/lib/Support/Host.cpp
@@ -1311,6 +1311,28 @@
}
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();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85531.283913.patch
Type: text/x-patch
Size: 2214 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200807/c7dbae7a/attachment.bin>
More information about the llvm-commits
mailing list