-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add logical objectFifo hoisting pass #679
Conversation
@@ -213,6 +213,11 @@ def AMDAIEHoistForLoopAffineApply : Pass<"iree-amdaie-hoist-for-affine-apply"> { | |||
let constructor = "mlir::iree_compiler::AMDAIE::createAMDAIEHoistForLoopAffineApplyPass()"; | |||
} | |||
|
|||
def AMDAIEHoistLogicalObjFifo : Pass<"iree-amdaie-hoist-logical-objectfifo"> { | |||
let summary = "Hoist logical objectFifo operations to the scope of its operands."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let summary = "Hoist logical objectFifo operations to the scope of its operands."; | |
let summary = "Hoist logical objectFifo operations to the scope of a most nested operand, without hoisting through workgroup, controlcode, or func ops."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it makes sense to not hoist through these ops because they're isolated from above (could you check that instead?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scrap that idea, they're not isolated from above
AMDAIE::LogicalObjectFifoFromMemrefOp op) { | ||
Operation *parentOp = op; | ||
while (parentOp) { | ||
Operation *newParentOp = parentOp->getParentOp(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I interpret this as
"If the new parent is a proper ancestor of any operand, keep hoisting"
which seems like not what you want?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"If the new parent is a proper ancestor of any operand, keep hoisting"
No, then it breaks,
Operation *parentOp = getOperation(); | ||
IRRewriter rewriter(parentOp->getContext()); | ||
parentOp->walk([&](AMDAIE::LogicalObjectFifoFromMemrefOp op) { | ||
(void)hoistLogicalObjFifoOp(rewriter, op); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if walk
enumerates all the ops it will visit before hand, I don't think so, so I think you actually visit all the hoisted ops twice (once after hoisting) here.
FWIW I find code that
- walk to find targets
- process targets
easier to grok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so I think you actually visit all the hoisted ops twice (once after hoisting)
The hoisted ops will be inserted before the ancestor op, so should not be visited again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes, you're right.
907b52a
to
1e82b7d
Compare
1e82b7d
to
53e7b1e
Compare
@newling Could you help check the PR again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Apologies for inserting noise with invalid concerns last time
Operation *parentOp = getOperation(); | ||
IRRewriter rewriter(parentOp->getContext()); | ||
parentOp->walk([&](AMDAIE::LogicalObjectFifoFromMemrefOp op) { | ||
(void)hoistLogicalObjFifoOp(rewriter, op); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes, you're right.
Follow-up on #676, which blocks subsumption when operands are in the same scope. Hoists
amdaie.logicalobjectfifo.from_memref
ops as much as possible, which enables more subsumption opportunities.