Skip to content

Commit

Permalink
[ThinLTO] Default backend threads to heavyweight_hardware_concurrency
Browse files Browse the repository at this point in the history
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

llvm-svn: 284618
  • Loading branch information
teresajohnson committed Oct 19, 2016
1 parent 69d7cf0 commit ec544c5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
4 changes: 3 additions & 1 deletion llvm/lib/LTO/LTO.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions llvm/lib/LTO/ThinLTOCodeGenerator.cpp
Expand Up @@ -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"
Expand All @@ -64,8 +65,8 @@ extern cl::opt<bool> LTODiscardValueNames;

namespace {

static cl::opt<int> ThreadCount("threads",
cl::init(std::thread::hardware_concurrency()));
static cl::opt<int>
ThreadCount("threads", cl::init(llvm::heavyweight_hardware_concurrency()));

static void diagnosticHandler(const DiagnosticInfo &DI) {
DiagnosticPrinterRawOStream DP(errs());
Expand Down
4 changes: 2 additions & 2 deletions llvm/tools/gold/gold-plugin.cpp
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion llvm/tools/llvm-lto2/llvm-lto2.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -52,7 +53,7 @@ static cl::opt<bool>
"distributed backend case"));

static cl::opt<int> Threads("-thinlto-threads",
cl::init(thread::hardware_concurrency()));
cl::init(llvm::heavyweight_hardware_concurrency()));

static cl::list<std::string> SymbolResolutions(
"r",
Expand Down

0 comments on commit ec544c5

Please sign in to comment.