[Mlir-commits] [mlir] b55fa20 - [MLIR][NFC] Retire let constructor for Async (#137461)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Apr 28 00:31:35 PDT 2025


Author: lorenzo chelini
Date: 2025-04-28T09:31:31+02:00
New Revision: b55fa20d838cff48d060b8f211795bc8b84c265b

URL: https://github.com/llvm/llvm-project/commit/b55fa20d838cff48d060b8f211795bc8b84c265b
DIFF: https://github.com/llvm/llvm-project/commit/b55fa20d838cff48d060b8f211795bc8b84c265b.diff

LOG: [MLIR][NFC] Retire let constructor for Async (#137461)

let constructor is legacy (do not use in tree!) since the tableGen
backend emits most of the glue logic to build a pass.

Note: The following constructor has been retired:

```cpp
std::unique_ptr<Pass> createAsyncParallelForPass(bool asyncDispatch,
                                                 int32_t numWorkerThreads,
                                                 int32_t minTaskSize);
```

To update your codebase, replace it with the new options-based API:

```cpp
AsyncParallelForPassOptions options{/*asyncDispatch=*/, /*numWorkerThreads=*/, /*minTaskSize=*/};
createAsyncParallelForPass(options);
```

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/Async/Passes.h
    mlir/include/mlir/Dialect/Async/Passes.td
    mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp
    mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCounting.cpp
    mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCountingOpt.cpp
    mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/Async/Passes.h b/mlir/include/mlir/Dialect/Async/Passes.h
index 090768cd0209c..20831d2a71187 100644
--- a/mlir/include/mlir/Dialect/Async/Passes.h
+++ b/mlir/include/mlir/Dialect/Async/Passes.h
@@ -22,25 +22,9 @@ class ConversionTarget;
 #define GEN_PASS_DECL
 #include "mlir/Dialect/Async/Passes.h.inc"
 
-std::unique_ptr<Pass> createAsyncParallelForPass();
-
-std::unique_ptr<Pass> createAsyncParallelForPass(bool asyncDispatch,
-                                                 int32_t numWorkerThreads,
-                                                 int32_t minTaskSize);
-
 void populateAsyncFuncToAsyncRuntimeConversionPatterns(
     RewritePatternSet &patterns, ConversionTarget &target);
 
-std::unique_ptr<OperationPass<ModuleOp>> createAsyncFuncToAsyncRuntimePass();
-
-std::unique_ptr<OperationPass<ModuleOp>> createAsyncToAsyncRuntimePass();
-
-std::unique_ptr<Pass> createAsyncRuntimeRefCountingPass();
-
-std::unique_ptr<Pass> createAsyncRuntimeRefCountingOptPass();
-
-std::unique_ptr<Pass> createAsyncRuntimePolicyBasedRefCountingPass();
-
 //===----------------------------------------------------------------------===//
 // Registration
 //===----------------------------------------------------------------------===//

diff  --git a/mlir/include/mlir/Dialect/Async/Passes.td b/mlir/include/mlir/Dialect/Async/Passes.td
index f0ef83ca3fd4f..8bbb542d3acf4 100644
--- a/mlir/include/mlir/Dialect/Async/Passes.td
+++ b/mlir/include/mlir/Dialect/Async/Passes.td
@@ -11,10 +11,9 @@
 
 include "mlir/Pass/PassBase.td"
 
-def AsyncParallelFor : Pass<"async-parallel-for", "ModuleOp"> {
+def AsyncParallelForPass : Pass<"async-parallel-for", "ModuleOp"> {
   let summary = "Convert scf.parallel operations to multiple async compute ops "
                 "executed concurrently for non-overlapping iteration ranges";
-  let constructor = "mlir::createAsyncParallelForPass()";
 
   let options = [
     Option<"asyncDispatch", "async-dispatch",
@@ -41,21 +40,20 @@ def AsyncParallelFor : Pass<"async-parallel-for", "ModuleOp"> {
   ];
 }
 
-def AsyncToAsyncRuntime : Pass<"async-to-async-runtime", "ModuleOp"> {
+def AsyncToAsyncRuntimePass : Pass<"async-to-async-runtime", "ModuleOp"> {
   let summary = "Lower all high level async operations (e.g. async.execute) to"
                 "the explicit async.runtime and async.coro operations";
-  let constructor = "mlir::createAsyncToAsyncRuntimePass()";
   let dependentDialects = ["async::AsyncDialect", "func::FuncDialect", "cf::ControlFlowDialect"];
 }
 
-def AsyncFuncToAsyncRuntime : Pass<"async-func-to-async-runtime", "ModuleOp"> {
+def AsyncFuncToAsyncRuntimePass
+    : Pass<"async-func-to-async-runtime", "ModuleOp"> {
   let summary = "Lower async.func operations to the explicit async.runtime and"
                 "async.coro operations";
-  let constructor = "mlir::createAsyncFuncToAsyncRuntimePass()";
   let dependentDialects = ["async::AsyncDialect", "func::FuncDialect"];
 }
 
-def AsyncRuntimeRefCounting : Pass<"async-runtime-ref-counting"> {
+def AsyncRuntimeRefCountingPass : Pass<"async-runtime-ref-counting"> {
   let summary = "Automatic reference counting for Async runtime operations";
   let description = [{
     This pass works at the async runtime abtraction level, after all
@@ -68,18 +66,17 @@ def AsyncRuntimeRefCounting : Pass<"async-runtime-ref-counting"> {
     See: https://llvm.org/docs/Coroutines.html#switched-resume-lowering
   }];
 
-  let constructor = "mlir::createAsyncRuntimeRefCountingPass()";
   let dependentDialects = ["async::AsyncDialect"];
 }
 
-def AsyncRuntimeRefCountingOpt : Pass<"async-runtime-ref-counting-opt"> {
+def AsyncRuntimeRefCountingOptPass : Pass<"async-runtime-ref-counting-opt"> {
   let summary = "Optimize automatic reference counting operations for the"
                 "Async runtime by removing redundant operations";
-  let constructor = "mlir::createAsyncRuntimeRefCountingOptPass()";
+
   let dependentDialects = ["async::AsyncDialect"];
 }
 
-def AsyncRuntimePolicyBasedRefCounting
+def AsyncRuntimePolicyBasedRefCountingPass
     : Pass<"async-runtime-policy-based-ref-counting"> {
   let summary = "Policy based reference counting for Async runtime operations";
   let description = [{
@@ -107,7 +104,6 @@ def AsyncRuntimePolicyBasedRefCounting
     automatic reference counting.
   }];
 
-  let constructor = "mlir::createAsyncRuntimePolicyBasedRefCountingPass()";
   let dependentDialects = ["async::AsyncDialect"];
 }
 

diff  --git a/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp b/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp
index 1320523aa989d..9c776dfa176a4 100644
--- a/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp
+++ b/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp
@@ -28,7 +28,7 @@
 #include <utility>
 
 namespace mlir {
-#define GEN_PASS_DEF_ASYNCPARALLELFOR
+#define GEN_PASS_DEF_ASYNCPARALLELFORPASS
 #include "mlir/Dialect/Async/Passes.h.inc"
 } // namespace mlir
 
@@ -99,15 +99,8 @@ namespace {
 //   }
 //
 struct AsyncParallelForPass
-    : public impl::AsyncParallelForBase<AsyncParallelForPass> {
-  AsyncParallelForPass() = default;
-
-  AsyncParallelForPass(bool asyncDispatch, int32_t numWorkerThreads,
-                       int32_t minTaskSize) {
-    this->asyncDispatch = asyncDispatch;
-    this->numWorkerThreads = numWorkerThreads;
-    this->minTaskSize = minTaskSize;
-  }
+    : public impl::AsyncParallelForPassBase<AsyncParallelForPass> {
+  using Base::Base;
 
   void runOnOperation() override;
 };
@@ -935,17 +928,6 @@ void AsyncParallelForPass::runOnOperation() {
     signalPassFailure();
 }
 
-std::unique_ptr<Pass> mlir::createAsyncParallelForPass() {
-  return std::make_unique<AsyncParallelForPass>();
-}
-
-std::unique_ptr<Pass> mlir::createAsyncParallelForPass(bool asyncDispatch,
-                                                       int32_t numWorkerThreads,
-                                                       int32_t minTaskSize) {
-  return std::make_unique<AsyncParallelForPass>(asyncDispatch, numWorkerThreads,
-                                                minTaskSize);
-}
-
 void mlir::async::populateAsyncParallelForPatterns(
     RewritePatternSet &patterns, bool asyncDispatch, int32_t numWorkerThreads,
     const AsyncMinTaskSizeComputationFunction &computeMinTaskSize) {

diff  --git a/mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCounting.cpp b/mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCounting.cpp
index 5cc30b629aef4..27a51c8cba769 100644
--- a/mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCounting.cpp
+++ b/mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCounting.cpp
@@ -23,8 +23,8 @@
 #include "llvm/ADT/SmallSet.h"
 
 namespace mlir {
-#define GEN_PASS_DEF_ASYNCRUNTIMEREFCOUNTING
-#define GEN_PASS_DEF_ASYNCRUNTIMEPOLICYBASEDREFCOUNTING
+#define GEN_PASS_DEF_ASYNCRUNTIMEREFCOUNTINGPASS
+#define GEN_PASS_DEF_ASYNCRUNTIMEPOLICYBASEDREFCOUNTINGPASS
 #include "mlir/Dialect/Async/Passes.h.inc"
 } // namespace mlir
 
@@ -109,7 +109,8 @@ static LogicalResult walkReferenceCountedValues(
 namespace {
 
 class AsyncRuntimeRefCountingPass
-    : public impl::AsyncRuntimeRefCountingBase<AsyncRuntimeRefCountingPass> {
+    : public impl::AsyncRuntimeRefCountingPassBase<
+          AsyncRuntimeRefCountingPass> {
 public:
   AsyncRuntimeRefCountingPass() = default;
   void runOnOperation() override;
@@ -468,7 +469,7 @@ void AsyncRuntimeRefCountingPass::runOnOperation() {
 namespace {
 
 class AsyncRuntimePolicyBasedRefCountingPass
-    : public impl::AsyncRuntimePolicyBasedRefCountingBase<
+    : public impl::AsyncRuntimePolicyBasedRefCountingPassBase<
           AsyncRuntimePolicyBasedRefCountingPass> {
 public:
   AsyncRuntimePolicyBasedRefCountingPass() { initializeDefaultPolicy(); }
@@ -553,13 +554,3 @@ void AsyncRuntimePolicyBasedRefCountingPass::runOnOperation() {
   if (failed(walkReferenceCountedValues(getOperation(), functor)))
     signalPassFailure();
 }
-
-//----------------------------------------------------------------------------//
-
-std::unique_ptr<Pass> mlir::createAsyncRuntimeRefCountingPass() {
-  return std::make_unique<AsyncRuntimeRefCountingPass>();
-}
-
-std::unique_ptr<Pass> mlir::createAsyncRuntimePolicyBasedRefCountingPass() {
-  return std::make_unique<AsyncRuntimePolicyBasedRefCountingPass>();
-}

diff  --git a/mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCountingOpt.cpp b/mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCountingOpt.cpp
index e4504df93b82d..48e2cf8e2b006 100644
--- a/mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCountingOpt.cpp
+++ b/mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCountingOpt.cpp
@@ -18,7 +18,7 @@
 #include "llvm/Support/Debug.h"
 
 namespace mlir {
-#define GEN_PASS_DEF_ASYNCRUNTIMEREFCOUNTINGOPT
+#define GEN_PASS_DEF_ASYNCRUNTIMEREFCOUNTINGOPTPASS
 #include "mlir/Dialect/Async/Passes.h.inc"
 } // namespace mlir
 
@@ -30,7 +30,7 @@ using namespace mlir::async;
 namespace {
 
 class AsyncRuntimeRefCountingOptPass
-    : public impl::AsyncRuntimeRefCountingOptBase<
+    : public impl::AsyncRuntimeRefCountingOptPassBase<
           AsyncRuntimeRefCountingOptPass> {
 public:
   AsyncRuntimeRefCountingOptPass() = default;
@@ -230,7 +230,3 @@ void AsyncRuntimeRefCountingOptPass::runOnOperation() {
     kv.second->erase();
   }
 }
-
-std::unique_ptr<Pass> mlir::createAsyncRuntimeRefCountingOptPass() {
-  return std::make_unique<AsyncRuntimeRefCountingOptPass>();
-}

diff  --git a/mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp b/mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp
index 9b36bd964ef10..b6a014e2f0a31 100644
--- a/mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp
+++ b/mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp
@@ -32,8 +32,8 @@
 #include <optional>
 
 namespace mlir {
-#define GEN_PASS_DEF_ASYNCTOASYNCRUNTIME
-#define GEN_PASS_DEF_ASYNCFUNCTOASYNCRUNTIME
+#define GEN_PASS_DEF_ASYNCTOASYNCRUNTIMEPASS
+#define GEN_PASS_DEF_ASYNCFUNCTOASYNCRUNTIMEPASS
 #include "mlir/Dialect/Async/Passes.h.inc"
 } // namespace mlir
 
@@ -47,7 +47,7 @@ static constexpr const char kAsyncFnPrefix[] = "async_execute_fn";
 namespace {
 
 class AsyncToAsyncRuntimePass
-    : public impl::AsyncToAsyncRuntimeBase<AsyncToAsyncRuntimePass> {
+    : public impl::AsyncToAsyncRuntimePassBase<AsyncToAsyncRuntimePass> {
 public:
   AsyncToAsyncRuntimePass() = default;
   void runOnOperation() override;
@@ -58,7 +58,8 @@ class AsyncToAsyncRuntimePass
 namespace {
 
 class AsyncFuncToAsyncRuntimePass
-    : public impl::AsyncFuncToAsyncRuntimeBase<AsyncFuncToAsyncRuntimePass> {
+    : public impl::AsyncFuncToAsyncRuntimePassBase<
+          AsyncFuncToAsyncRuntimePass> {
 public:
   AsyncFuncToAsyncRuntimePass() = default;
   void runOnOperation() override;
@@ -896,12 +897,3 @@ void AsyncFuncToAsyncRuntimePass::runOnOperation() {
     return;
   }
 }
-
-std::unique_ptr<OperationPass<ModuleOp>> mlir::createAsyncToAsyncRuntimePass() {
-  return std::make_unique<AsyncToAsyncRuntimePass>();
-}
-
-std::unique_ptr<OperationPass<ModuleOp>>
-mlir::createAsyncFuncToAsyncRuntimePass() {
-  return std::make_unique<AsyncFuncToAsyncRuntimePass>();
-}


        


More information about the Mlir-commits mailing list