summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Fuzzer/FuzzerUtil.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/Fuzzer/FuzzerUtil.cpp
parentc1f906c134feab3d5602e869f0983b8b35f18394 (diff)
downloadbcm5719-llvm-6e182fbab46d61ea6bef31719fb4524dac85ae9f.tar.gz
bcm5719-llvm-6e182fbab46d61ea6bef31719fb4524dac85ae9f.zip
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/Fuzzer/FuzzerUtil.cpp')
-rw-r--r--llvm/lib/Fuzzer/FuzzerUtil.cpp10
1 files changed, 1 insertions, 9 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerUtil.cpp b/llvm/lib/Fuzzer/FuzzerUtil.cpp
index f5a77737449..5f76ddc3678 100644
--- a/llvm/lib/Fuzzer/FuzzerUtil.cpp
+++ b/llvm/lib/Fuzzer/FuzzerUtil.cpp
@@ -195,15 +195,7 @@ void PrintPC(const char *SymbolizedFMT, const char *FallbackFMT, uintptr_t PC) {
Printf(FallbackFMT, PC);
}
-unsigned NumberOfCpuCores() {
- unsigned N = std::thread::hardware_concurrency();
- if (!N) {
- Printf("WARNING: std::thread::hardware_concurrency not well defined for "
- "your platform. Assuming CPU count of 1.\n");
- N = 1;
- }
- return N;
-}
+unsigned NumberOfCpuCores() { return hardware_concurrency(); }
size_t SimpleFastHash(const uint8_t *Data, size_t Size) {
size_t Res = 0;
OpenPOWER on IntegriCloud