[Mlir-commits] [llvm] [mlir] Split the llvm::ThreadPool into an abstract base class and an impleme… (PR #82094)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri Feb 16 22:01:58 PST 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 7106389b25436538f0373484a8ab0428ea681410 dfdf757a684204bcc7ae0a57850a2e41a4b0a4c5 -- llvm/include/llvm/Support/ThreadPool.h llvm/lib/Support/ThreadPool.cpp mlir/include/mlir/IR/MLIRContext.h mlir/include/mlir/IR/Threading.h mlir/lib/CAPI/IR/IR.cpp mlir/lib/IR/MLIRContext.cpp mlir/lib/Pass/Pass.cpp mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/include/llvm/Support/ThreadPool.h b/llvm/include/llvm/Support/ThreadPool.h
index b0dc3ce50e..0962db27f4 100644
--- a/llvm/include/llvm/Support/ThreadPool.h
+++ b/llvm/include/llvm/Support/ThreadPool.h
@@ -32,7 +32,6 @@ namespace llvm {
class ThreadPoolTaskGroup;
-
/// This defines the abstract base interface for a ThreadPool allowing
/// asynchronous parallel execution on a defined number of threads.
///
@@ -48,13 +47,14 @@ class ThreadPoolTaskGroup;
/// left to run on (this includes waiting on the returned future). It should be
/// generally safe to wait() for a group as long as groups do not form a cycle.
class ThreadPoolInterface {
- // The actual method to enqueue a task to be defined by the concrete implementation.
- virtual void asyncEnqueue(std::function<void()> Task, ThreadPoolTaskGroup *Group) = 0;
+ // The actual method to enqueue a task to be defined by the concrete
+ // implementation.
+ virtual void asyncEnqueue(std::function<void()> Task,
+ ThreadPoolTaskGroup *Group) = 0;
public:
-
- // Destroying the pool will drain the pending tasks and wait. The current thread may
- // participate in the execution of the pending tasks.
+ // Destroying the pool will drain the pending tasks and wait. The current
+ // thread may participate in the execution of the pending tasks.
virtual ~ThreadPoolInterface();
/// Blocking wait for all the threads to complete and the queue to be empty.
@@ -72,7 +72,6 @@ public:
// Returns the maximum number of worker this pool can eventually grow to.
virtual unsigned getMaxConcurrency() const = 0;
-
/// Asynchronous submission of a task to the pool. The returned future can be
/// used to wait for the task to finish and is *non-blocking* on destruction.
template <typename Function, typename... Args>
@@ -106,7 +105,6 @@ public:
}
private:
-
/// Asynchronous submission of a task to the pool. The returned future can be
/// used to wait for the task to finish and is *non-blocking* on destruction.
template <typename ResTy>
@@ -173,7 +171,6 @@ public:
/// Blocking destructor: the pool will wait for all the threads to complete.
~ThreadPool() override;
-
/// Blocking wait for all the threads to complete and the queue to be empty.
/// It is an error to try to add new tasks while blocking on this call.
/// Calling wait() from a task would deadlock waiting for itself.
@@ -192,21 +189,18 @@ public:
unsigned getThreadCount() const { return MaxThreadCount; }
unsigned getMaxConcurrency() const override { return MaxThreadCount; }
-
/// Returns true if the current thread is a worker thread of this thread pool.
bool isWorkerThread() const;
private:
-
/// Returns true if all tasks in the given group have finished (nullptr means
/// all tasks regardless of their group). QueueLock must be locked.
bool workCompletedUnlocked(ThreadPoolTaskGroup *Group) const;
-
/// Asynchronous submission of a task to the pool. The returned future can be
/// used to wait for the task to finish and is *non-blocking* on destruction.
void asyncEnqueue(std::function<void()> Task,
- ThreadPoolTaskGroup *Group) override {
+ ThreadPoolTaskGroup *Group) override {
#if LLVM_ENABLE_THREADS
int requestedThreads;
{
``````````
</details>
https://github.com/llvm/llvm-project/pull/82094
More information about the Mlir-commits
mailing list