From: Teresa Johnson Date: Wed, 19 Oct 2016 17:35:01 +0000 (+0000) Subject: [ThinLTO] Default backend threads to heavyweight_hardware_concurrency X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=740d871c3ea53e7f90f0f1a848189ccdd17acb3d;p=llvm [ThinLTO] Default backend threads to heavyweight_hardware_concurrency Summary: Changes default backend parallelism from thread::hardware_concurrency to the new llvm::heavyweight_hardware_concurrency, which for X86 Linux defaults to the number of physical cores (and will fall back to thread::hardware_concurrency otherwise). This avoid oversubscribing the physical cores using hyperthreading. Reviewers: mehdi_amini, pcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D25775 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284618 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/LTO/LTO.cpp b/lib/LTO/LTO.cpp index 65bcef6370d..b4efb4a4db6 100644 --- a/lib/LTO/LTO.cpp +++ b/lib/LTO/LTO.cpp @@ -29,6 +29,7 @@ #include "llvm/Support/SourceMgr.h" #include "llvm/Support/TargetRegistry.h" #include "llvm/Support/ThreadPool.h" +#include "llvm/Support/Threading.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" @@ -227,7 +228,8 @@ LTO::RegularLTOState::RegularLTOState(unsigned ParallelCodeGenParallelismLevel, LTO::ThinLTOState::ThinLTOState(ThinBackend Backend) : Backend(Backend) { if (!Backend) - this->Backend = createInProcessThinBackend(thread::hardware_concurrency()); + this->Backend = + createInProcessThinBackend(llvm::heavyweight_hardware_concurrency()); } LTO::LTO(Config Conf, ThinBackend Backend, diff --git a/lib/LTO/ThinLTOCodeGenerator.cpp b/lib/LTO/ThinLTOCodeGenerator.cpp index 10af9870ccb..578b3e88b01 100644 --- a/lib/LTO/ThinLTOCodeGenerator.cpp +++ b/lib/LTO/ThinLTOCodeGenerator.cpp @@ -43,6 +43,7 @@ #include "llvm/Support/SHA1.h" #include "llvm/Support/TargetRegistry.h" #include "llvm/Support/ThreadPool.h" +#include "llvm/Support/Threading.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/IPO/FunctionImport.h" @@ -64,8 +65,8 @@ extern cl::opt LTODiscardValueNames; namespace { -static cl::opt ThreadCount("threads", - cl::init(std::thread::hardware_concurrency())); +static cl::opt + ThreadCount("threads", cl::init(llvm::heavyweight_hardware_concurrency())); static void diagnosticHandler(const DiagnosticInfo &DI) { DiagnosticPrinterRawOStream DP(errs()); diff --git a/tools/gold/gold-plugin.cpp b/tools/gold/gold-plugin.cpp index 055c462e69a..1366c0f77fd 100644 --- a/tools/gold/gold-plugin.cpp +++ b/tools/gold/gold-plugin.cpp @@ -118,8 +118,8 @@ namespace options { static unsigned OptLevel = 2; // Default parallelism of 0 used to indicate that user did not specify. // Actual parallelism default value depends on implementation. - // Currently only affects ThinLTO, where the default is the - // hardware_concurrency. + // Currently only affects ThinLTO, where the default is + // llvm::heavyweight_hardware_concurrency. static unsigned Parallelism = 0; // Default regular LTO codegen parallelism (number of partitions). static unsigned ParallelCodeGenParallelismLevel = 1; diff --git a/tools/llvm-lto2/llvm-lto2.cpp b/tools/llvm-lto2/llvm-lto2.cpp index a3cc6ef14d1..042f874596f 100644 --- a/tools/llvm-lto2/llvm-lto2.cpp +++ b/tools/llvm-lto2/llvm-lto2.cpp @@ -20,6 +20,7 @@ #include "llvm/LTO/LTO.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/TargetSelect.h" +#include "llvm/Support/Threading.h" using namespace llvm; using namespace lto; @@ -52,7 +53,7 @@ static cl::opt "distributed backend case")); static cl::opt Threads("-thinlto-threads", - cl::init(thread::hardware_concurrency())); + cl::init(llvm::heavyweight_hardware_concurrency())); static cl::list SymbolResolutions( "r",