Skip to content

Commit dad3162

Browse files
authored
[mlir][OpenMP] Allow 'cancel taskgroup' inside taskloop region (#138634)
Added support which allows "cancel taskgroup" inside taskloop region.
1 parent 43a9d5d commit dad3162

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -3217,7 +3217,8 @@ LogicalResult CancelOp::verify() {
32173217
}
32183218
}
32193219
if ((cct == ClauseCancellationConstructType::Taskgroup) &&
3220-
!mlir::isa<omp::TaskOp>(structuralParent)) {
3220+
(!mlir::isa<omp::TaskOp>(structuralParent) &&
3221+
!mlir::isa<omp::TaskloopOp>(structuralParent->getParentOp()))) {
32213222
return emitOpError() << "cancel taskgroup must appear "
32223223
<< "inside a task region";
32233224
}

mlir/test/Dialect/OpenMP/ops.mlir

+12
Original file line numberDiff line numberDiff line change
@@ -2215,6 +2215,18 @@ func.func @omp_cancel_taskgroup() -> () {
22152215
return
22162216
}
22172217

2218+
func.func @omp_taskloop_cancel_taskgroup(%lb : index, %ub : index, %step : index) {
2219+
omp.taskloop {
2220+
omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {
2221+
// CHECK: omp.cancel cancellation_construct_type(taskgroup)
2222+
omp.cancel cancellation_construct_type(taskgroup)
2223+
// CHECK: omp.yield
2224+
omp.yield
2225+
}
2226+
}
2227+
return
2228+
}
2229+
22182230
func.func @omp_cancel_parallel_nested(%if_cond : i1) -> () {
22192231
omp.parallel {
22202232
scf.if %if_cond {

0 commit comments

Comments
 (0)