-
Notifications
You must be signed in to change notification settings - Fork 52
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
[Loop Specialization]: Specialize loops containing masked operations with loop invariant mask #3586
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Tiotto, Ettore <[email protected]>
Signed-off-by: Tiotto, Ettore <[email protected]>
Signed-off-by: Tiotto, Ettore <[email protected]>
Signed-off-by: Tiotto, Ettore <[email protected]>
…ith loop invariant masks Signed-off-by: Tiotto, Ettore <[email protected]>
@@ -3,9 +3,9 @@ | |||
#include "mlir/Dialect/Arith/IR/Arith.h" | |||
#include "mlir/Dialect/SCF/IR/SCF.h" | |||
#include "mlir/IR/Verifier.h" | |||
// #include "mlir/Pass/Pass.h" |
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.
Remove
class VersioningCondition { | ||
// Abstract base class for mask validators. | ||
// Mask validators are used to check whether a given mask has an expected form. | ||
// Concreate subclasses define the expected form. |
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.
Typo: Concreate -> Concrete
Signed-off-by: Tiotto, Ettore <[email protected]>
static bool version(scf::ForOp &forOp, | ||
MaskedOpsCollector<CanonicalMaskValidator> &collector) { | ||
// Limitation | ||
// Currently we can version the loop only is it doesn't have downward |
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.
// Currently we can version the loop only is it doesn't have downward | |
// Currently we can version the loop only if it doesn't have downward |
// Combine the versioning conditions. | ||
OpBuilder builder(forOp); | ||
Location loc = forOp.getLoc(); | ||
auto it = maskConds.begin(); | ||
Value firstCond = (*it++)->getResult(0); | ||
auto maskValidator = collector.getMaskValidator(); | ||
Value verCond = maskValidator.getVersioningCond(forOp, firstCond); | ||
for (; it != maskConds.end(); ++it) { | ||
Value nextCond = (*it)->getResult(0); | ||
Value cond = maskValidator.getVersioningCond(forOp, nextCond); | ||
verCond = builder.create<arith::AndIOp>(loc, verCond, cond); | ||
} |
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.
Would that make sense to create a third (and fourth?) branch if only load (or store) masks can be removed?
I think that it is still interesting to use 2D block loads even if store operations cannot not use 2D block store.
WDYT?
Version loops containing masked operations (e.g. tt.load with a mask) where the mask is loop invariant.