[PATCH] D38481: Use sched_getaffinity instead of std::thread::hardware_concurrency when available

Rafael Ávila de Espíndola via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 2 15:58:18 PDT 2017


rafael created this revision.
Herald added a subscriber: mgorny.

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.


https://reviews.llvm.org/D38481

Files:
  cmake/config-ix.cmake
  include/llvm/Config/config.h.cmake
  include/llvm/Support/ThreadPool.h
  include/llvm/Support/Threading.h
  lib/Fuzzer/FuzzerUtil.cpp
  lib/Support/Parallel.cpp
  lib/Support/ThreadPool.cpp
  lib/Support/Threading.cpp
  tools/llvm-profdata/llvm-profdata.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38481.117442.patch
Type: text/x-patch
Size: 6099 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171002/6130fd25/attachment.bin>


More information about the llvm-commits mailing list