aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/Threading.cpp
diff options
context:
space:
mode:
authorArchibald Elliott <archibald.elliott@arm.com>2022-11-25 16:25:19 +0000
committerArchibald Elliott <archibald.elliott@arm.com>2022-11-29 13:14:13 +0000
commit3c97f6cab92fb3511d72996ac7ca8a8b459ebc88 (patch)
tree99346d95eeef02eb97284053af27afe087001e71 /llvm/lib/Support/Threading.cpp
parent6b8900f7f91de489302886c7e48033407d13f8c1 (diff)
downloadllvm-3c97f6cab92fb3511d72996ac7ca8a8b459ebc88.zip
llvm-3c97f6cab92fb3511d72996ac7ca8a8b459ebc88.tar.gz
llvm-3c97f6cab92fb3511d72996ac7ca8a8b459ebc88.tar.bz2
[Support] Move getHostNumPhysicalCores to Threading.h
This change is focussed on simplifying `Support/Host.h` to only do target detection. In this case, this function is close in usage to existing functions in `Support/Threading.h`, so I moved it into there. The function is also renamed to `llvm::get_physical_cores()` to match the style of threading's functions. The big change here is that now if you have threading disabled, `llvm::get_physical_cores()` will return -1, as if it had not been able to work out the right info. This is due to how Threading.cpp includes OS-specific code/headers. This seems ok, as if threading is disabled, LLVM should not need to know the number of physical cores. Differential Revision: https://reviews.llvm.org/D137836
Diffstat (limited to 'llvm/lib/Support/Threading.cpp')
-rw-r--r--llvm/lib/Support/Threading.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/Support/Threading.cpp b/llvm/lib/Support/Threading.cpp
index bd954fd..910437c 100644
--- a/llvm/lib/Support/Threading.cpp
+++ b/llvm/lib/Support/Threading.cpp
@@ -14,7 +14,7 @@
#include "llvm/Support/Threading.h"
#include "llvm/ADT/Optional.h"
#include "llvm/Config/config.h"
-#include "llvm/Support/Host.h"
+#include "llvm/Config/llvm-config.h"
#include <cassert>
#include <errno.h>
@@ -45,13 +45,16 @@ unsigned llvm::ThreadPoolStrategy::compute_thread_count() const {
return 1;
}
+// Unknown if threading turned off
+int llvm::get_physical_cores() { return -1; }
+
#else
static int computeHostNumHardwareThreads();
unsigned llvm::ThreadPoolStrategy::compute_thread_count() const {
- int MaxThreadCount = UseHyperThreads ? computeHostNumHardwareThreads()
- : sys::getHostNumPhysicalCores();
+ int MaxThreadCount =
+ UseHyperThreads ? computeHostNumHardwareThreads() : get_physical_cores();
if (MaxThreadCount <= 0)
MaxThreadCount = 1;
if (ThreadsRequested == 0)