[PATCH] D84764: Fix computeHostNumPhysicalCores() for Linux on POWER and Linux on Z

Ettore Tiotto via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 30 11:06:06 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG36a4f1037628: Fix computeHostNumPhysicalCores() for Linux on POWER and Linux on Z (authored by etiotto).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84764/new/

https://reviews.llvm.org/D84764

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
@@ -40,7 +40,9 @@
     // x86_64 Linux and Darwin.
     return (Host.isOSWindows() && llvm_is_multithreaded()) ||
            (Host.isX86() &&
-            (Host.isOSDarwin() || Host.getOS() == Triple::Linux));
+            (Host.isOSDarwin() || Host.getOS() == Triple::Linux)) ||
+           (Host.getOS() == Triple::Linux &&
+            (Host.isPPC64() || Host.isSystemZ()));
   }
 
   HostTest() : Host(Triple::normalize(sys::getProcessTriple())) {}
Index: llvm/lib/Support/Host.cpp
===================================================================
--- llvm/lib/Support/Host.cpp
+++ llvm/lib/Support/Host.cpp
@@ -1271,6 +1271,12 @@
   }
   return CPU_COUNT(&Enabled);
 }
+#elif (defined(__linux__) &&                                                   \
+       (defined(__ppc__) || defined(__powerpc__) || defined(__s390x__)))
+#include <unistd.h>
+
+// Gets the number of *physical cores* on the machine.
+int computeHostNumPhysicalCores() { return sysconf(_SC_NPROCESSORS_ONLN); }
 #elif defined(__APPLE__) && defined(__x86_64__)
 #include <sys/param.h>
 #include <sys/sysctl.h>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84764.281992.patch
Type: text/x-patch
Size: 1266 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200730/ec98ff50/attachment.bin>


More information about the llvm-commits mailing list