[llvm] 93b553e - Revert "Host: Internalize computeHostNumPhysicalCores/computeHostNumHardwareThreads"
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 23 20:12:23 PST 2022
Author: Fangrui Song
Date: 2022-11-23T20:12:16-08:00
New Revision: 93b553e3f2e4f53ce3dda13cd18dbc43643a535b
URL: https://github.com/llvm/llvm-project/commit/93b553e3f2e4f53ce3dda13cd18dbc43643a535b
DIFF: https://github.com/llvm/llvm-project/commit/93b553e3f2e4f53ce3dda13cd18dbc43643a535b.diff
LOG: Revert "Host: Internalize computeHostNumPhysicalCores/computeHostNumHardwareThreads"
This reverts commit 9969ceb36b440eaafa17c486f29a69c7a7da3b3b.
On Windows:
lld-link: error: undefined symbol: int __cdecl computeHostNumPhysicalCores(void)
>>> referenced by LLVMSupport.lib(Support.Host.obj):(int __cdecl llvm::sys::getHostNumPhysicalCores(void))
Added:
Modified:
llvm/lib/Support/Host.cpp
llvm/lib/Support/Threading.cpp
llvm/lib/Support/Unix/Threading.inc
llvm/lib/Support/Windows/Threading.inc
Removed:
################################################################################
diff --git a/llvm/lib/Support/Host.cpp b/llvm/lib/Support/Host.cpp
index 8361997723bee..6bb452a854b1a 100644
--- a/llvm/lib/Support/Host.cpp
+++ b/llvm/lib/Support/Host.cpp
@@ -1580,7 +1580,7 @@ VendorSignatures getVendorSignature(unsigned *MaxLeaf) {
// On Linux, the number of physical cores can be computed from /proc/cpuinfo,
// using the number of unique physical/core id pairs. The following
// implementation reads the /proc/cpuinfo format on an x86_64 system.
-static int computeHostNumPhysicalCores() {
+int computeHostNumPhysicalCores() {
// Enabled represents the number of physical id/core id pairs with at least
// one processor id enabled by the CPU affinity mask.
cpu_set_t Affinity, Enabled;
@@ -1625,11 +1625,9 @@ static int computeHostNumPhysicalCores() {
return CPU_COUNT(&Enabled);
}
#elif defined(__linux__) && defined(__s390x__)
-static int computeHostNumPhysicalCores() {
- return sysconf(_SC_NPROCESSORS_ONLN);
-}
+int computeHostNumPhysicalCores() { return sysconf(_SC_NPROCESSORS_ONLN); }
#elif defined(__linux__) && !defined(__ANDROID__)
-static int computeHostNumPhysicalCores() {
+int computeHostNumPhysicalCores() {
cpu_set_t Affinity;
if (sched_getaffinity(0, sizeof(Affinity), &Affinity) == 0)
return CPU_COUNT(&Affinity);
@@ -1649,7 +1647,7 @@ static int computeHostNumPhysicalCores() {
}
#elif defined(__APPLE__)
// Gets the number of *physical cores* on the machine.
-static int computeHostNumPhysicalCores() {
+int computeHostNumPhysicalCores() {
uint32_t count;
size_t len = sizeof(count);
sysctlbyname("hw.physicalcpu", &count, &len, NULL, 0);
@@ -1664,7 +1662,7 @@ static int computeHostNumPhysicalCores() {
return count;
}
#elif defined(__MVS__)
-static int computeHostNumPhysicalCores() {
+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
@@ -1687,7 +1685,7 @@ static int computeHostNumPhysicalCores() {
}
#elif defined(_WIN32) && LLVM_ENABLE_THREADS != 0
// Defined in llvm/lib/Support/Windows/Threading.inc
-static int computeHostNumPhysicalCores();
+int computeHostNumPhysicalCores();
#else
// On other systems, return -1 to indicate unknown.
static int computeHostNumPhysicalCores() { return -1; }
diff --git a/llvm/lib/Support/Threading.cpp b/llvm/lib/Support/Threading.cpp
index bd954fd7c85aa..b14ff9549e438 100644
--- a/llvm/lib/Support/Threading.cpp
+++ b/llvm/lib/Support/Threading.cpp
@@ -47,7 +47,7 @@ unsigned llvm::ThreadPoolStrategy::compute_thread_count() const {
#else
-static int computeHostNumHardwareThreads();
+int computeHostNumHardwareThreads();
unsigned llvm::ThreadPoolStrategy::compute_thread_count() const {
int MaxThreadCount = UseHyperThreads ? computeHostNumHardwareThreads()
diff --git a/llvm/lib/Support/Unix/Threading.inc b/llvm/lib/Support/Unix/Threading.inc
index 6a67401500317..99f64b4f553d8 100644
--- a/llvm/lib/Support/Unix/Threading.inc
+++ b/llvm/lib/Support/Unix/Threading.inc
@@ -290,7 +290,7 @@ SetThreadPriorityResult llvm::set_thread_priority(ThreadPriority Priority) {
#include <thread>
-static int computeHostNumHardwareThreads() {
+int computeHostNumHardwareThreads() {
#if defined(__FreeBSD__)
cpuset_t mask;
CPU_ZERO(&mask);
diff --git a/llvm/lib/Support/Windows/Threading.inc b/llvm/lib/Support/Windows/Threading.inc
index 5b8640076a25b..11f34817dbbfc 100644
--- a/llvm/lib/Support/Windows/Threading.inc
+++ b/llvm/lib/Support/Windows/Threading.inc
@@ -239,7 +239,7 @@ static unsigned aggregate(R &&Range, UnaryPredicate P) {
}
// for sys::getHostNumPhysicalCores
-static int computeHostNumPhysicalCores() {
+int computeHostNumPhysicalCores() {
static unsigned Cores =
aggregate(getProcessorGroups(), [](const ProcessorGroup &G) {
return G.UsableThreads / G.ThreadsPerCore;
@@ -247,7 +247,7 @@ static int computeHostNumPhysicalCores() {
return Cores;
}
-static int computeHostNumHardwareThreads() {
+int computeHostNumHardwareThreads() {
static unsigned Threads =
aggregate(getProcessorGroups(),
[](const ProcessorGroup &G) { return G.UsableThreads; });
More information about the llvm-commits
mailing list