Skip to content

Commit ec544c5

Browse files
committedOct 19, 2016
[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 llvm-svn: 284618
1 parent 69d7cf0 commit ec544c5

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed
 

‎llvm/lib/LTO/LTO.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "llvm/Support/SourceMgr.h"
3030
#include "llvm/Support/TargetRegistry.h"
3131
#include "llvm/Support/ThreadPool.h"
32+
#include "llvm/Support/Threading.h"
3233
#include "llvm/Support/raw_ostream.h"
3334
#include "llvm/Target/TargetMachine.h"
3435
#include "llvm/Target/TargetOptions.h"
@@ -227,7 +228,8 @@ LTO::RegularLTOState::RegularLTOState(unsigned ParallelCodeGenParallelismLevel,
227228

228229
LTO::ThinLTOState::ThinLTOState(ThinBackend Backend) : Backend(Backend) {
229230
if (!Backend)
230-
this->Backend = createInProcessThinBackend(thread::hardware_concurrency());
231+
this->Backend =
232+
createInProcessThinBackend(llvm::heavyweight_hardware_concurrency());
231233
}
232234

233235
LTO::LTO(Config Conf, ThinBackend Backend,

‎llvm/lib/LTO/ThinLTOCodeGenerator.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include "llvm/Support/SHA1.h"
4444
#include "llvm/Support/TargetRegistry.h"
4545
#include "llvm/Support/ThreadPool.h"
46+
#include "llvm/Support/Threading.h"
4647
#include "llvm/Target/TargetMachine.h"
4748
#include "llvm/Transforms/IPO.h"
4849
#include "llvm/Transforms/IPO/FunctionImport.h"
@@ -64,8 +65,8 @@ extern cl::opt<bool> LTODiscardValueNames;
6465

6566
namespace {
6667

67-
static cl::opt<int> ThreadCount("threads",
68-
cl::init(std::thread::hardware_concurrency()));
68+
static cl::opt<int>
69+
ThreadCount("threads", cl::init(llvm::heavyweight_hardware_concurrency()));
6970

7071
static void diagnosticHandler(const DiagnosticInfo &DI) {
7172
DiagnosticPrinterRawOStream DP(errs());

‎llvm/tools/gold/gold-plugin.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ namespace options {
118118
static unsigned OptLevel = 2;
119119
// Default parallelism of 0 used to indicate that user did not specify.
120120
// Actual parallelism default value depends on implementation.
121-
// Currently only affects ThinLTO, where the default is the
122-
// hardware_concurrency.
121+
// Currently only affects ThinLTO, where the default is
122+
// llvm::heavyweight_hardware_concurrency.
123123
static unsigned Parallelism = 0;
124124
// Default regular LTO codegen parallelism (number of partitions).
125125
static unsigned ParallelCodeGenParallelismLevel = 1;

‎llvm/tools/llvm-lto2/llvm-lto2.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "llvm/LTO/LTO.h"
2121
#include "llvm/Support/CommandLine.h"
2222
#include "llvm/Support/TargetSelect.h"
23+
#include "llvm/Support/Threading.h"
2324

2425
using namespace llvm;
2526
using namespace lto;
@@ -52,7 +53,7 @@ static cl::opt<bool>
5253
"distributed backend case"));
5354

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

5758
static cl::list<std::string> SymbolResolutions(
5859
"r",

0 commit comments

Comments
 (0)
Please sign in to comment.