-
Notifications
You must be signed in to change notification settings - Fork 12k
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
[MLIR][OpenMP] Update op verifiers dependent on omp.wsloop (2/5) #89211
[MLIR][OpenMP] Update op verifiers dependent on omp.wsloop (2/5) #89211
Conversation
This patch updates the definition of `omp.wsloop` to enforce the restrictions of a loop wrapper operation. Related tests are updated but this PR on its own will not pass premerge tests. All patches in the stack are needed before it can be compiled and passes tests.
This patch updates verifiers for `omp.ordered.region`, `omp.cancel` and `omp.cancellation_point`, which check for a parent `omp.wsloop`. After transitioning to a loop wrapper-based approach, the expected direct parent will become `omp.loop_nest` instead, so verifiers need to take this into account. This PR on its own will not pass premerge tests. All patches in the stack are needed before it can be compiled and passes tests.
@llvm/pr-subscribers-mlir @llvm/pr-subscribers-flang-openmp Author: Sergio Afonso (skatrak) ChangesThis patch updates verifiers for After transitioning to a loop wrapper-based approach, the expected direct parent will become This PR on its own will not pass premerge tests. All patches in the stack are needed before it can be compiled and passes tests. Full diff: https://github.com/llvm/llvm-project/pull/89211.diff 1 Files Affected:
diff --git a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
index d66186effc31d6..d014c27e1ee157 100644
--- a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
+++ b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
@@ -1977,9 +1977,10 @@ LogicalResult OrderedRegionOp::verify() {
if (getSimd())
return failure();
- if (auto container = (*this)->getParentOfType<WsloopOp>()) {
- if (!container.getOrderedValAttr() ||
- container.getOrderedValAttr().getInt() != 0)
+ if (auto loopOp = dyn_cast<LoopNestOp>((*this)->getParentOp())) {
+ auto wsloopOp = llvm::dyn_cast_if_present<WsloopOp>(loopOp->getParentOp());
+ if (!wsloopOp || !wsloopOp.getOrderedValAttr() ||
+ wsloopOp.getOrderedValAttr().getInt() != 0)
return emitOpError() << "ordered region must be closely nested inside "
<< "a worksharing-loop region with an ordered "
<< "clause without parameter present";
@@ -2130,15 +2131,19 @@ LogicalResult CancelOp::verify() {
<< "inside a parallel region";
}
if (cct == ClauseCancellationConstructType::Loop) {
- if (!isa<WsloopOp>(parentOp)) {
- return emitOpError() << "cancel loop must appear "
- << "inside a worksharing-loop region";
+ auto loopOp = dyn_cast<LoopNestOp>(parentOp);
+ auto wsloopOp = llvm::dyn_cast_if_present<WsloopOp>(
+ loopOp ? loopOp->getParentOp() : nullptr);
+
+ if (!wsloopOp) {
+ return emitOpError()
+ << "cancel loop must appear inside a worksharing-loop region";
}
- if (cast<WsloopOp>(parentOp).getNowaitAttr()) {
+ if (wsloopOp.getNowaitAttr()) {
return emitError() << "A worksharing construct that is canceled "
<< "must not have a nowait clause";
}
- if (cast<WsloopOp>(parentOp).getOrderedValAttr()) {
+ if (wsloopOp.getOrderedValAttr()) {
return emitError() << "A worksharing construct that is canceled "
<< "must not have an ordered clause";
}
@@ -2176,7 +2181,7 @@ LogicalResult CancellationPointOp::verify() {
<< "inside a parallel region";
}
if ((cct == ClauseCancellationConstructType::Loop) &&
- !isa<WsloopOp>(parentOp)) {
+ (!isa<LoopNestOp>(parentOp) || !isa<WsloopOp>(parentOp->getParentOp()))) {
return emitOpError() << "cancellation point loop must appear "
<< "inside a worksharing-loop region";
}
|
@llvm/pr-subscribers-mlir-openmp Author: Sergio Afonso (skatrak) ChangesThis patch updates verifiers for After transitioning to a loop wrapper-based approach, the expected direct parent will become This PR on its own will not pass premerge tests. All patches in the stack are needed before it can be compiled and passes tests. Full diff: https://github.com/llvm/llvm-project/pull/89211.diff 1 Files Affected:
diff --git a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
index d66186effc31d6..d014c27e1ee157 100644
--- a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
+++ b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
@@ -1977,9 +1977,10 @@ LogicalResult OrderedRegionOp::verify() {
if (getSimd())
return failure();
- if (auto container = (*this)->getParentOfType<WsloopOp>()) {
- if (!container.getOrderedValAttr() ||
- container.getOrderedValAttr().getInt() != 0)
+ if (auto loopOp = dyn_cast<LoopNestOp>((*this)->getParentOp())) {
+ auto wsloopOp = llvm::dyn_cast_if_present<WsloopOp>(loopOp->getParentOp());
+ if (!wsloopOp || !wsloopOp.getOrderedValAttr() ||
+ wsloopOp.getOrderedValAttr().getInt() != 0)
return emitOpError() << "ordered region must be closely nested inside "
<< "a worksharing-loop region with an ordered "
<< "clause without parameter present";
@@ -2130,15 +2131,19 @@ LogicalResult CancelOp::verify() {
<< "inside a parallel region";
}
if (cct == ClauseCancellationConstructType::Loop) {
- if (!isa<WsloopOp>(parentOp)) {
- return emitOpError() << "cancel loop must appear "
- << "inside a worksharing-loop region";
+ auto loopOp = dyn_cast<LoopNestOp>(parentOp);
+ auto wsloopOp = llvm::dyn_cast_if_present<WsloopOp>(
+ loopOp ? loopOp->getParentOp() : nullptr);
+
+ if (!wsloopOp) {
+ return emitOpError()
+ << "cancel loop must appear inside a worksharing-loop region";
}
- if (cast<WsloopOp>(parentOp).getNowaitAttr()) {
+ if (wsloopOp.getNowaitAttr()) {
return emitError() << "A worksharing construct that is canceled "
<< "must not have a nowait clause";
}
- if (cast<WsloopOp>(parentOp).getOrderedValAttr()) {
+ if (wsloopOp.getOrderedValAttr()) {
return emitError() << "A worksharing construct that is canceled "
<< "must not have an ordered clause";
}
@@ -2176,7 +2181,7 @@ LogicalResult CancellationPointOp::verify() {
<< "inside a parallel region";
}
if ((cct == ClauseCancellationConstructType::Loop) &&
- !isa<WsloopOp>(parentOp)) {
+ (!isa<LoopNestOp>(parentOp) || !isa<WsloopOp>(parentOp->getParentOp()))) {
return emitOpError() << "cancellation point loop must appear "
<< "inside a worksharing-loop region";
}
|
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.
LGTM
…atrak/spr/wsloop-wrapper-02-dependent-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.
LGTM. I'm sorry this fell off my radar
…atrak/spr/wsloop-wrapper-02-dependent-ops
…atrak/spr/wsloop-wrapper-02-dependent-ops
This patch updates verifiers for
omp.ordered
,omp.ordered.region
,omp.cancel
andomp.cancellation_point
, which check for a parentomp.wsloop
.After transitioning to a loop wrapper-based approach, the expected direct parent will become
omp.loop_nest
instead, so verifiers need to take this into account.This PR on its own will not pass premerge tests. All patches in the stack are needed before it can be compiled and passes tests.