aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/Parallel.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2017-10-03 16:25:15 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2017-10-03 16:25:15 +0000
commit6e182fbab46d61ea6bef31719fb4524dac85ae9f (patch)
tree127149647aa8306e3bbca82fc319407732a2191b /llvm/lib/Support/Parallel.cpp
parentc1f906c134feab3d5602e869f0983b8b35f18394 (diff)
downloadllvm-6e182fbab46d61ea6bef31719fb4524dac85ae9f.zip
llvm-6e182fbab46d61ea6bef31719fb4524dac85ae9f.tar.gz
llvm-6e182fbab46d61ea6bef31719fb4524dac85ae9f.tar.bz2
Use sched_getaffinity instead of std::thread::hardware_concurrency.
The issue with std::thread::hardware_concurrency is that it forwards to libc and some implementations (like glibc) don't take thread affinity into consideration. With this change a llvm program that can execute in only 2 cores will use 2 threads, even if the machine has 32 cores. This makes benchmarking a lot easier, but should also help if someone doesn't want to use all cores for compilation for example. llvm-svn: 314809
Diffstat (limited to 'llvm/lib/Support/Parallel.cpp')
-rw-r--r--llvm/lib/Support/Parallel.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Support/Parallel.cpp b/llvm/lib/Support/Parallel.cpp
index ab2cfde..010e429 100644
--- a/llvm/lib/Support/Parallel.cpp
+++ b/llvm/lib/Support/Parallel.cpp
@@ -9,6 +9,7 @@
#include "llvm/Support/Parallel.h"
#include "llvm/Config/llvm-config.h"
+#include "llvm/Support/Threading.h"
#include <atomic>
#include <stack>
@@ -70,8 +71,7 @@ Executor *Executor::getDefaultExecutor() {
/// in filo order.
class ThreadPoolExecutor : public Executor {
public:
- explicit ThreadPoolExecutor(
- unsigned ThreadCount = std::thread::hardware_concurrency())
+ explicit ThreadPoolExecutor(unsigned ThreadCount = hardware_concurrency())
: Done(ThreadCount) {
// Spawn all but one of the threads in another thread as spawning threads
// can take a while.