Skip to content

Commit 9cedd52

Browse files
cheliniIanWood1
authored andcommitted
[MLIR][NFC] Retire let constructor for Async (llvm#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); ```
1 parent be9fba7 commit 9cedd52

File tree

6 files changed

+23
-82
lines changed

6 files changed

+23
-82
lines changed

mlir/include/mlir/Dialect/Async/Passes.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,9 @@ class ConversionTarget;
2222
#define GEN_PASS_DECL
2323
#include "mlir/Dialect/Async/Passes.h.inc"
2424

25-
std::unique_ptr<Pass> createAsyncParallelForPass();
26-
27-
std::unique_ptr<Pass> createAsyncParallelForPass(bool asyncDispatch,
28-
int32_t numWorkerThreads,
29-
int32_t minTaskSize);
30-
3125
void populateAsyncFuncToAsyncRuntimeConversionPatterns(
3226
RewritePatternSet &patterns, ConversionTarget &target);
3327

34-
std::unique_ptr<OperationPass<ModuleOp>> createAsyncFuncToAsyncRuntimePass();
35-
36-
std::unique_ptr<OperationPass<ModuleOp>> createAsyncToAsyncRuntimePass();
37-
38-
std::unique_ptr<Pass> createAsyncRuntimeRefCountingPass();
39-
40-
std::unique_ptr<Pass> createAsyncRuntimeRefCountingOptPass();
41-
42-
std::unique_ptr<Pass> createAsyncRuntimePolicyBasedRefCountingPass();
43-
4428
//===----------------------------------------------------------------------===//
4529
// Registration
4630
//===----------------------------------------------------------------------===//

mlir/include/mlir/Dialect/Async/Passes.td

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@
1111

1212
include "mlir/Pass/PassBase.td"
1313

14-
def AsyncParallelFor : Pass<"async-parallel-for", "ModuleOp"> {
14+
def AsyncParallelForPass : Pass<"async-parallel-for", "ModuleOp"> {
1515
let summary = "Convert scf.parallel operations to multiple async compute ops "
1616
"executed concurrently for non-overlapping iteration ranges";
17-
let constructor = "mlir::createAsyncParallelForPass()";
1817

1918
let options = [
2019
Option<"asyncDispatch", "async-dispatch",
@@ -41,21 +40,20 @@ def AsyncParallelFor : Pass<"async-parallel-for", "ModuleOp"> {
4140
];
4241
}
4342

44-
def AsyncToAsyncRuntime : Pass<"async-to-async-runtime", "ModuleOp"> {
43+
def AsyncToAsyncRuntimePass : Pass<"async-to-async-runtime", "ModuleOp"> {
4544
let summary = "Lower all high level async operations (e.g. async.execute) to"
4645
"the explicit async.runtime and async.coro operations";
47-
let constructor = "mlir::createAsyncToAsyncRuntimePass()";
4846
let dependentDialects = ["async::AsyncDialect", "func::FuncDialect", "cf::ControlFlowDialect"];
4947
}
5048

51-
def AsyncFuncToAsyncRuntime : Pass<"async-func-to-async-runtime", "ModuleOp"> {
49+
def AsyncFuncToAsyncRuntimePass
50+
: Pass<"async-func-to-async-runtime", "ModuleOp"> {
5251
let summary = "Lower async.func operations to the explicit async.runtime and"
5352
"async.coro operations";
54-
let constructor = "mlir::createAsyncFuncToAsyncRuntimePass()";
5553
let dependentDialects = ["async::AsyncDialect", "func::FuncDialect"];
5654
}
5755

58-
def AsyncRuntimeRefCounting : Pass<"async-runtime-ref-counting"> {
56+
def AsyncRuntimeRefCountingPass : Pass<"async-runtime-ref-counting"> {
5957
let summary = "Automatic reference counting for Async runtime operations";
6058
let description = [{
6159
This pass works at the async runtime abtraction level, after all
@@ -68,18 +66,17 @@ def AsyncRuntimeRefCounting : Pass<"async-runtime-ref-counting"> {
6866
See: https://llvm.org/docs/Coroutines.html#switched-resume-lowering
6967
}];
7068

71-
let constructor = "mlir::createAsyncRuntimeRefCountingPass()";
7269
let dependentDialects = ["async::AsyncDialect"];
7370
}
7471

75-
def AsyncRuntimeRefCountingOpt : Pass<"async-runtime-ref-counting-opt"> {
72+
def AsyncRuntimeRefCountingOptPass : Pass<"async-runtime-ref-counting-opt"> {
7673
let summary = "Optimize automatic reference counting operations for the"
7774
"Async runtime by removing redundant operations";
78-
let constructor = "mlir::createAsyncRuntimeRefCountingOptPass()";
75+
7976
let dependentDialects = ["async::AsyncDialect"];
8077
}
8178

82-
def AsyncRuntimePolicyBasedRefCounting
79+
def AsyncRuntimePolicyBasedRefCountingPass
8380
: Pass<"async-runtime-policy-based-ref-counting"> {
8481
let summary = "Policy based reference counting for Async runtime operations";
8582
let description = [{
@@ -107,7 +104,6 @@ def AsyncRuntimePolicyBasedRefCounting
107104
automatic reference counting.
108105
}];
109106

110-
let constructor = "mlir::createAsyncRuntimePolicyBasedRefCountingPass()";
111107
let dependentDialects = ["async::AsyncDialect"];
112108
}
113109

mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include <utility>
2929

3030
namespace mlir {
31-
#define GEN_PASS_DEF_ASYNCPARALLELFOR
31+
#define GEN_PASS_DEF_ASYNCPARALLELFORPASS
3232
#include "mlir/Dialect/Async/Passes.h.inc"
3333
} // namespace mlir
3434

@@ -99,15 +99,8 @@ namespace {
9999
// }
100100
//
101101
struct AsyncParallelForPass
102-
: public impl::AsyncParallelForBase<AsyncParallelForPass> {
103-
AsyncParallelForPass() = default;
104-
105-
AsyncParallelForPass(bool asyncDispatch, int32_t numWorkerThreads,
106-
int32_t minTaskSize) {
107-
this->asyncDispatch = asyncDispatch;
108-
this->numWorkerThreads = numWorkerThreads;
109-
this->minTaskSize = minTaskSize;
110-
}
102+
: public impl::AsyncParallelForPassBase<AsyncParallelForPass> {
103+
using Base::Base;
111104

112105
void runOnOperation() override;
113106
};
@@ -935,17 +928,6 @@ void AsyncParallelForPass::runOnOperation() {
935928
signalPassFailure();
936929
}
937930

938-
std::unique_ptr<Pass> mlir::createAsyncParallelForPass() {
939-
return std::make_unique<AsyncParallelForPass>();
940-
}
941-
942-
std::unique_ptr<Pass> mlir::createAsyncParallelForPass(bool asyncDispatch,
943-
int32_t numWorkerThreads,
944-
int32_t minTaskSize) {
945-
return std::make_unique<AsyncParallelForPass>(asyncDispatch, numWorkerThreads,
946-
minTaskSize);
947-
}
948-
949931
void mlir::async::populateAsyncParallelForPatterns(
950932
RewritePatternSet &patterns, bool asyncDispatch, int32_t numWorkerThreads,
951933
const AsyncMinTaskSizeComputationFunction &computeMinTaskSize) {

mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCounting.cpp

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
#include "llvm/ADT/SmallSet.h"
2424

2525
namespace mlir {
26-
#define GEN_PASS_DEF_ASYNCRUNTIMEREFCOUNTING
27-
#define GEN_PASS_DEF_ASYNCRUNTIMEPOLICYBASEDREFCOUNTING
26+
#define GEN_PASS_DEF_ASYNCRUNTIMEREFCOUNTINGPASS
27+
#define GEN_PASS_DEF_ASYNCRUNTIMEPOLICYBASEDREFCOUNTINGPASS
2828
#include "mlir/Dialect/Async/Passes.h.inc"
2929
} // namespace mlir
3030

@@ -109,7 +109,8 @@ static LogicalResult walkReferenceCountedValues(
109109
namespace {
110110

111111
class AsyncRuntimeRefCountingPass
112-
: public impl::AsyncRuntimeRefCountingBase<AsyncRuntimeRefCountingPass> {
112+
: public impl::AsyncRuntimeRefCountingPassBase<
113+
AsyncRuntimeRefCountingPass> {
113114
public:
114115
AsyncRuntimeRefCountingPass() = default;
115116
void runOnOperation() override;
@@ -468,7 +469,7 @@ void AsyncRuntimeRefCountingPass::runOnOperation() {
468469
namespace {
469470

470471
class AsyncRuntimePolicyBasedRefCountingPass
471-
: public impl::AsyncRuntimePolicyBasedRefCountingBase<
472+
: public impl::AsyncRuntimePolicyBasedRefCountingPassBase<
472473
AsyncRuntimePolicyBasedRefCountingPass> {
473474
public:
474475
AsyncRuntimePolicyBasedRefCountingPass() { initializeDefaultPolicy(); }
@@ -553,13 +554,3 @@ void AsyncRuntimePolicyBasedRefCountingPass::runOnOperation() {
553554
if (failed(walkReferenceCountedValues(getOperation(), functor)))
554555
signalPassFailure();
555556
}
556-
557-
//----------------------------------------------------------------------------//
558-
559-
std::unique_ptr<Pass> mlir::createAsyncRuntimeRefCountingPass() {
560-
return std::make_unique<AsyncRuntimeRefCountingPass>();
561-
}
562-
563-
std::unique_ptr<Pass> mlir::createAsyncRuntimePolicyBasedRefCountingPass() {
564-
return std::make_unique<AsyncRuntimePolicyBasedRefCountingPass>();
565-
}

mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCountingOpt.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "llvm/Support/Debug.h"
1919

2020
namespace mlir {
21-
#define GEN_PASS_DEF_ASYNCRUNTIMEREFCOUNTINGOPT
21+
#define GEN_PASS_DEF_ASYNCRUNTIMEREFCOUNTINGOPTPASS
2222
#include "mlir/Dialect/Async/Passes.h.inc"
2323
} // namespace mlir
2424

@@ -30,7 +30,7 @@ using namespace mlir::async;
3030
namespace {
3131

3232
class AsyncRuntimeRefCountingOptPass
33-
: public impl::AsyncRuntimeRefCountingOptBase<
33+
: public impl::AsyncRuntimeRefCountingOptPassBase<
3434
AsyncRuntimeRefCountingOptPass> {
3535
public:
3636
AsyncRuntimeRefCountingOptPass() = default;
@@ -230,7 +230,3 @@ void AsyncRuntimeRefCountingOptPass::runOnOperation() {
230230
kv.second->erase();
231231
}
232232
}
233-
234-
std::unique_ptr<Pass> mlir::createAsyncRuntimeRefCountingOptPass() {
235-
return std::make_unique<AsyncRuntimeRefCountingOptPass>();
236-
}

mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
#include <optional>
3333

3434
namespace mlir {
35-
#define GEN_PASS_DEF_ASYNCTOASYNCRUNTIME
36-
#define GEN_PASS_DEF_ASYNCFUNCTOASYNCRUNTIME
35+
#define GEN_PASS_DEF_ASYNCTOASYNCRUNTIMEPASS
36+
#define GEN_PASS_DEF_ASYNCFUNCTOASYNCRUNTIMEPASS
3737
#include "mlir/Dialect/Async/Passes.h.inc"
3838
} // namespace mlir
3939

@@ -47,7 +47,7 @@ static constexpr const char kAsyncFnPrefix[] = "async_execute_fn";
4747
namespace {
4848

4949
class AsyncToAsyncRuntimePass
50-
: public impl::AsyncToAsyncRuntimeBase<AsyncToAsyncRuntimePass> {
50+
: public impl::AsyncToAsyncRuntimePassBase<AsyncToAsyncRuntimePass> {
5151
public:
5252
AsyncToAsyncRuntimePass() = default;
5353
void runOnOperation() override;
@@ -58,7 +58,8 @@ class AsyncToAsyncRuntimePass
5858
namespace {
5959

6060
class AsyncFuncToAsyncRuntimePass
61-
: public impl::AsyncFuncToAsyncRuntimeBase<AsyncFuncToAsyncRuntimePass> {
61+
: public impl::AsyncFuncToAsyncRuntimePassBase<
62+
AsyncFuncToAsyncRuntimePass> {
6263
public:
6364
AsyncFuncToAsyncRuntimePass() = default;
6465
void runOnOperation() override;
@@ -896,12 +897,3 @@ void AsyncFuncToAsyncRuntimePass::runOnOperation() {
896897
return;
897898
}
898899
}
899-
900-
std::unique_ptr<OperationPass<ModuleOp>> mlir::createAsyncToAsyncRuntimePass() {
901-
return std::make_unique<AsyncToAsyncRuntimePass>();
902-
}
903-
904-
std::unique_ptr<OperationPass<ModuleOp>>
905-
mlir::createAsyncFuncToAsyncRuntimePass() {
906-
return std::make_unique<AsyncFuncToAsyncRuntimePass>();
907-
}

0 commit comments

Comments
 (0)