Skip to content

Commit

Permalink
Remove barriers post execution scheduling
Browse files Browse the repository at this point in the history
Once scheduling is complete we will no longer need the barrier
operators. Removing the operations now prevents the copy during
allocation.
  • Loading branch information
rsuderman committed Jan 20, 2025
1 parent 4c600ca commit f64501e
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,15 @@ LogicalResult processRegion(Location loc, MLIRContext *context, Region &region,
// --iree-stream-schedule-execution
//===----------------------------------------------------------------------===//

struct RemoveBarriers : public OpRewritePattern<IREE::Stream::AsyncBarrierOp> {
using OpRewritePattern::OpRewritePattern;
LogicalResult matchAndRewrite(IREE::Stream::AsyncBarrierOp op,
PatternRewriter &rewriter) const override {
rewriter.replaceOp(op, op.getOperand(0));
return success();
}
};

struct ScheduleExecutionPass
: public IREE::Stream::impl::ScheduleExecutionPassBase<
ScheduleExecutionPass> {
Expand Down Expand Up @@ -347,6 +356,8 @@ struct ScheduleExecutionPass
for (auto op : context->getRegisteredOperations()) {
op.getCanonicalizationPatterns(patterns, context);
}

patterns.insert<RemoveBarriers>(context);
FrozenRewritePatternSet frozenPatterns(std::move(patterns));
if (failed(applyPatternsGreedily(getOperation(), frozenPatterns))) {
return signalPassFailure();
Expand Down

0 comments on commit f64501e

Please sign in to comment.