Skip to content

Use the new ThreadPoolInterface base class instead of the concrete implementation (NFC) #84056

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bolt/include/bolt/Core/ParallelUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ enum SchedulingPolicy {
SP_BB_QUADRATIC, /// cost is estimated by the square of the BB count
};

/// Return the managed thread pool and initialize it if not initiliazed.
ThreadPool &getThreadPool();
/// Return the managed thread pool and initialize it if not initialized.
ThreadPoolInterface &getThreadPool();

/// Perform the work on each BinaryFunction except those that are accepted
/// by SkipPredicate, scheduling heuristic is based on SchedPolicy.
Expand Down
6 changes: 3 additions & 3 deletions bolt/lib/Core/ParallelUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ inline unsigned estimateTotalCost(const BinaryContext &BC,

} // namespace

ThreadPool &getThreadPool() {
ThreadPoolInterface &getThreadPool() {
if (ThreadPoolPtr.get())
return *ThreadPoolPtr;

Expand Down Expand Up @@ -145,7 +145,7 @@ void runOnEachFunction(BinaryContext &BC, SchedulingPolicy SchedPolicy,
TotalCost > BlocksCount ? TotalCost / BlocksCount : 1;

// Divide work into blocks of equal cost
ThreadPool &Pool = getThreadPool();
ThreadPoolInterface &Pool = getThreadPool();
auto BlockBegin = BC.getBinaryFunctions().begin();
unsigned CurrentCost = 0;

Expand Down Expand Up @@ -202,7 +202,7 @@ void runOnEachFunctionWithUniqueAllocId(
TotalCost > BlocksCount ? TotalCost / BlocksCount : 1;

// Divide work into blocks of equal cost
ThreadPool &Pool = getThreadPool();
ThreadPoolInterface &Pool = getThreadPool();
auto BlockBegin = BC.getBinaryFunctions().begin();
unsigned CurrentCost = 0;
unsigned AllocId = 1;
Expand Down
2 changes: 1 addition & 1 deletion bolt/lib/Passes/IdenticalCodeFolding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ Error IdenticalCodeFolding::runOnFunctions(BinaryContext &BC) {
Timer SinglePass("single fold pass", "single fold pass");
LLVM_DEBUG(SinglePass.startTimer());

ThreadPool *ThPool;
ThreadPoolInterface *ThPool;
if (!opts::NoThreads)
ThPool = &ParallelUtilities::getThreadPool();

Expand Down
2 changes: 1 addition & 1 deletion bolt/lib/Rewrite/DWARFRewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ void DWARFRewriter::updateDebugInfo() {
}
} else {
// Update unit debug info in parallel
ThreadPool &ThreadPool = ParallelUtilities::getThreadPool();
ThreadPoolInterface &ThreadPool = ParallelUtilities::getThreadPool();
for (std::unique_ptr<DWARFUnit> &CU : BC.DwCtx->compile_units())
ThreadPool.async(processUnitDIE, CU.get(), &DIEBlder);
ThreadPool.wait();
Expand Down
4 changes: 2 additions & 2 deletions llvm/tools/llvm-reduce/deltas/Delta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ void llvm::runDeltaPass(TestRunner &Test, ReductionFunc ExtractChunksFromModule,
}

std::atomic<bool> AnyReduced;
std::unique_ptr<ThreadPool> ChunkThreadPoolPtr;
std::unique_ptr<ThreadPoolInterface> ChunkThreadPoolPtr;
if (NumJobs > 1)
ChunkThreadPoolPtr =
std::make_unique<ThreadPool>(hardware_concurrency(NumJobs));
Expand Down Expand Up @@ -251,7 +251,7 @@ void llvm::runDeltaPass(TestRunner &Test, ReductionFunc ExtractChunksFromModule,
unsigned NumInitialTasks = std::min(WorkLeft, unsigned(NumJobs));
unsigned NumChunksProcessed = 0;

ThreadPool &ChunkThreadPool = *ChunkThreadPoolPtr;
ThreadPoolInterface &ChunkThreadPool = *ChunkThreadPoolPtr;
assert(TaskQueue.empty());

AnyReduced = false;
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/ExecutionEngine/AsyncRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class AsyncRuntime {
return numRefCountedObjects.load(std::memory_order_relaxed);
}

llvm::ThreadPool &getThreadPool() { return threadPool; }
llvm::ThreadPoolInterface &getThreadPool() { return threadPool; }

private:
friend class RefCounted;
Expand Down