-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
Use the new ThreadPoolInterface base class instead of the concrete implementation (NFC) #84056
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…plementation (NFC)
joker-eph
requested review from
aaupov,
maksfb,
rafaelauler,
ayermolo and
dcci
as code owners
March 5, 2024 18:39
@llvm/pr-subscribers-mlir-execution-engine @llvm/pr-subscribers-mlir Author: Mehdi Amini (joker-eph) ChangesFull diff: https://github.com/llvm/llvm-project/pull/84056.diff 6 Files Affected:
diff --git a/bolt/include/bolt/Core/ParallelUtilities.h b/bolt/include/bolt/Core/ParallelUtilities.h
index e510525bc51d00..e7b35a79acc78c 100644
--- a/bolt/include/bolt/Core/ParallelUtilities.h
+++ b/bolt/include/bolt/Core/ParallelUtilities.h
@@ -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.
diff --git a/bolt/lib/Core/ParallelUtilities.cpp b/bolt/lib/Core/ParallelUtilities.cpp
index 1a28bc4346ecd5..88d9444a6a2ba7 100644
--- a/bolt/lib/Core/ParallelUtilities.cpp
+++ b/bolt/lib/Core/ParallelUtilities.cpp
@@ -102,7 +102,7 @@ inline unsigned estimateTotalCost(const BinaryContext &BC,
} // namespace
-ThreadPool &getThreadPool() {
+ThreadPoolInterface &getThreadPool() {
if (ThreadPoolPtr.get())
return *ThreadPoolPtr;
@@ -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;
@@ -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;
diff --git a/bolt/lib/Passes/IdenticalCodeFolding.cpp b/bolt/lib/Passes/IdenticalCodeFolding.cpp
index 9f8d82b05ccf48..87eba10354a37b 100644
--- a/bolt/lib/Passes/IdenticalCodeFolding.cpp
+++ b/bolt/lib/Passes/IdenticalCodeFolding.cpp
@@ -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();
diff --git a/bolt/lib/Rewrite/DWARFRewriter.cpp b/bolt/lib/Rewrite/DWARFRewriter.cpp
index ca9d24245ceb1d..85c2397dcc5b25 100644
--- a/bolt/lib/Rewrite/DWARFRewriter.cpp
+++ b/bolt/lib/Rewrite/DWARFRewriter.cpp
@@ -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();
diff --git a/llvm/tools/llvm-reduce/deltas/Delta.cpp b/llvm/tools/llvm-reduce/deltas/Delta.cpp
index 62dfd62a4d5a5f..569117e70d6b42 100644
--- a/llvm/tools/llvm-reduce/deltas/Delta.cpp
+++ b/llvm/tools/llvm-reduce/deltas/Delta.cpp
@@ -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));
@@ -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;
diff --git a/mlir/lib/ExecutionEngine/AsyncRuntime.cpp b/mlir/lib/ExecutionEngine/AsyncRuntime.cpp
index 189902969f8d2f..ec4a81c042c2c2 100644
--- a/mlir/lib/ExecutionEngine/AsyncRuntime.cpp
+++ b/mlir/lib/ExecutionEngine/AsyncRuntime.cpp
@@ -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;
|
dwblaikie
approved these changes
Mar 5, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.