Skip to content

Commit dd70528

Browse files
authored
Purge EnforceLoopCarriedDealloc, as the pass is now part of the canonicalizer (Xilinx#921)
1 parent 2d3e948 commit dd70528

File tree

4 files changed

+0
-203
lines changed

4 files changed

+0
-203
lines changed

mlir/include/air/Transform/AIRDependencyScheduleOpt.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ std::unique_ptr<mlir::Pass> createAIRDependencyScheduleOptPass();
4747

4848
std::unique_ptr<mlir::Pass> createAIRUnrollChannelByFactorPattern();
4949

50-
std::unique_ptr<mlir::Pass> createAIREnforceLoopCarriedMemrefDeallocPattern();
51-
5250
std::unique_ptr<mlir::Pass> createAIRFuseChannels();
5351
std::unique_ptr<OperationPass<ModuleOp>>
5452
createAIRFuseChannels(const AIRFuseChannelsOptions &);

mlir/include/air/Transform/Passes.td

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,15 +1001,6 @@ def AIRUnrollChannelByFactorPattern: Pass<"air-unroll-channel-by-factor", "Modul
10011001
];
10021002
}
10031003

1004-
def AIREnforceLoopCarriedMemrefDeallocPattern: Pass<"air-enforce-loop-carried-memref-dealloc", "ModuleOp"> {
1005-
let summary = "Enforce memref dealloc ops in loop iterations";
1006-
let constructor = "xilinx::air::createAIREnforceLoopCarriedMemrefDeallocPattern()";
1007-
let description = [{
1008-
This pass enforces memref deallocation events to happen within each loop
1009-
iteration, by connecting them in the loop-carried dependency path.
1010-
}];
1011-
}
1012-
10131004
def AIRFuseChannels: Pass<"air-fuse-channels", "ModuleOp"> {
10141005
let summary = "Fuse multiple air.channel ops into one";
10151006
let constructor = "xilinx::air::createAIRFuseChannels()";

mlir/lib/Transform/AIRDependencyScheduleOpt.cpp

Lines changed: 0 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,83 +1291,6 @@ struct ConstructPingPongDependencyPattern
12911291
}
12921292
};
12931293

1294-
struct EnforceLoopCarriedMemrefDeallocPattern
1295-
: public OpRewritePattern<scf::ForOp> {
1296-
using OpRewritePattern<scf::ForOp>::OpRewritePattern;
1297-
1298-
LogicalResult matchAndRewrite(scf::ForOp for_op,
1299-
PatternRewriter &rewriter) const override {
1300-
1301-
// Check if the loop has already been processed
1302-
scf::YieldOp yield_op =
1303-
dyn_cast<scf::YieldOp>(for_op.getBody()->getTerminator());
1304-
std::vector<air::ExecuteOp> disconnected_deallocs;
1305-
for (auto exec : for_op.getOps<air::ExecuteOp>()) {
1306-
for (auto dealloc : exec.getOps<memref::DeallocOp>()) {
1307-
(void)dealloc;
1308-
SmallVector<Operation *, 1> vec;
1309-
if (!hasPath(exec.getOperation(), yield_op.getOperation(), vec)) {
1310-
disconnected_deallocs.push_back(exec);
1311-
}
1312-
}
1313-
}
1314-
1315-
// Reconnect deallocs to loop-carried dependency path
1316-
if (!disconnected_deallocs.empty()) {
1317-
rewriter.setInsertionPoint(yield_op);
1318-
auto wa = rewriter.create<air::WaitAllOp>(
1319-
yield_op.getLoc(), air::AsyncTokenType::get(rewriter.getContext()),
1320-
yield_op->getOperands());
1321-
for (auto dealloc_exec : disconnected_deallocs) {
1322-
wa.addAsyncDependency(dealloc_exec.getAsyncToken());
1323-
}
1324-
rewriter.create<scf::YieldOp>(yield_op.getLoc(),
1325-
SmallVector<Value>{wa.getAsyncToken()});
1326-
rewriter.eraseOp(yield_op.getOperation());
1327-
}
1328-
1329-
return success();
1330-
}
1331-
1332-
private:
1333-
std::vector<Operation *> adjacent_events(Operation *event) const {
1334-
SmallVector<Value, 1> returned_tokens = {};
1335-
for (Value result : event->getResults()) {
1336-
if (llvm::isa<air::AsyncTokenType>(result.getType())) {
1337-
returned_tokens.push_back(result);
1338-
}
1339-
}
1340-
std::vector<Operation *> adj_set = {};
1341-
for (Value token : returned_tokens) {
1342-
for (Operation *user : token.getUsers()) {
1343-
adj_set.push_back(user);
1344-
}
1345-
}
1346-
return adj_set;
1347-
}
1348-
1349-
bool hasPath(Operation *start_event, Operation *end_event,
1350-
SmallVector<Operation *, 1> &vec) const {
1351-
vec.push_back(start_event);
1352-
if (start_event == end_event)
1353-
return true;
1354-
int pathCount = 0;
1355-
std::vector<Operation *> adj_set = adjacent_events(start_event);
1356-
for (auto adj_event : adj_set) {
1357-
SmallVector<Operation *, 1> tmp_vec;
1358-
if (hasPath(adj_event, end_event, tmp_vec)) {
1359-
pathCount++;
1360-
// Concatenate
1361-
vec.insert(vec.end(), tmp_vec.begin(), tmp_vec.end());
1362-
}
1363-
}
1364-
if (pathCount)
1365-
return true;
1366-
vec.pop_back();
1367-
return false;
1368-
}
1369-
};
1370-
13711294
struct HoistOpsNotUsingPingPongPattern : public OpRewritePattern<scf::ForOp> {
13721295
using OpRewritePattern<scf::ForOp>::OpRewritePattern;
13731296

@@ -3223,40 +3146,6 @@ class AIRDependencyScheduleOpt
32233146
private:
32243147
};
32253148

3226-
class AIREnforceLoopCarriedMemrefDeallocPattern
3227-
: public xilinx::air::impl::AIREnforceLoopCarriedMemrefDeallocPatternBase<
3228-
AIREnforceLoopCarriedMemrefDeallocPattern> {
3229-
3230-
public:
3231-
AIREnforceLoopCarriedMemrefDeallocPattern() = default;
3232-
AIREnforceLoopCarriedMemrefDeallocPattern(
3233-
const AIREnforceLoopCarriedMemrefDeallocPattern &pass) {}
3234-
3235-
void getDependentDialects(::mlir::DialectRegistry &registry) const override {
3236-
registry.insert<scf::SCFDialect, air::airDialect>();
3237-
}
3238-
3239-
void runOptPatterns(func::FuncOp funcOp) {
3240-
MLIRContext *ctx = funcOp.getContext();
3241-
RewritePatternSet patterns(&getContext());
3242-
patterns.insert<EnforceLoopCarriedMemrefDeallocPattern>(ctx);
3243-
(void)applyPatternsGreedily(funcOp, std::move(patterns));
3244-
}
3245-
3246-
void runOnFunction(func::FuncOp f) { runOptPatterns(f); }
3247-
3248-
void runOnOperation() override {
3249-
auto module = getOperation();
3250-
SmallVector<func::FuncOp, 4> funcOps;
3251-
module.walk([&](func::FuncOp op) { funcOps.push_back(op); });
3252-
for (auto f : funcOps) {
3253-
runOnFunction(f);
3254-
}
3255-
}
3256-
3257-
private:
3258-
};
3259-
32603149
// A pass which transform multiple channel ops into one, where the data movement
32613150
// is time-multiplexed.
32623151
class AIRFuseChannels
@@ -5999,10 +5888,6 @@ std::unique_ptr<Pass> createAIRUnrollChannelByFactorPattern() {
59995888
return std::make_unique<AIRUnrollChannelByFactorPattern>();
60005889
}
60015890

6002-
std::unique_ptr<Pass> createAIREnforceLoopCarriedMemrefDeallocPattern() {
6003-
return std::make_unique<AIREnforceLoopCarriedMemrefDeallocPattern>();
6004-
}
6005-
60065891
std::unique_ptr<Pass> createAIRFuseChannels() {
60075892
return std::make_unique<AIRFuseChannels>();
60085893
}

mlir/test/Transform/AIRDependencyScheduleOpt/enforce_loop_carried_dealloc.mlir

Lines changed: 0 additions & 77 deletions
This file was deleted.

0 commit comments

Comments
 (0)