Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3216,7 +3216,11 @@ LogicalResult CancelOp::verify() {
<< "must not have a nowait clause";
}
}
// TODO : Add more when we support taskgroup.
if ((cct == ClauseCancellationConstructType::Taskgroup) &&
!mlir::isa<omp::TaskOp>(structuralParent)) {
return emitOpError() << "cancel taskgroup must appear "
<< "inside a task region";
}
return success();
}

Expand Down Expand Up @@ -3253,7 +3257,11 @@ LogicalResult CancellationPointOp::verify() {
return emitOpError() << "cancellation point sections must appear "
<< "inside a sections region";
}
// TODO : Add more when we support taskgroup.
if ((cct == ClauseCancellationConstructType::Taskgroup) &&
!mlir::isa<omp::TaskOp>(structuralParent)) {
return emitOpError() << "cancellation point taskgroup must appear "
<< "inside a task region";
}
return success();
}

Expand Down
24 changes: 24 additions & 0 deletions mlir/test/Dialect/OpenMP/invalid.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -1754,6 +1754,18 @@ func.func @omp_cancel2() {

// -----

func.func @omp_cancel_taskloop() {
omp.sections {
// expected-error @below {{cancel taskgroup must appear inside a task region}}
omp.cancel cancellation_construct_type(taskgroup)
// CHECK: omp.terminator
omp.terminator
}
return
}

// -----

func.func @omp_cancel3(%arg1 : i32, %arg2 : i32, %arg3 : i32) -> () {
omp.wsloop nowait {
omp.loop_nest (%0) : i32 = (%arg1) to (%arg2) step (%arg3) {
Expand Down Expand Up @@ -1841,6 +1853,18 @@ func.func @omp_cancellationpoint2() {

// -----

func.func @omp_cancellationpoint_taskgroup() {
omp.sections {
// expected-error @below {{cancellation point taskgroup must appear inside a task region}}
omp.cancellation_point cancellation_construct_type(taskgroup)
// CHECK: omp.terminator
omp.terminator
}
return
}

// -----

omp.declare_reduction @add_f32 : f32
init {
^bb0(%arg: f32):
Expand Down
61 changes: 61 additions & 0 deletions mlir/test/Dialect/OpenMP/ops.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -2201,6 +2201,20 @@ func.func @omp_cancel_sections() -> () {
return
}

func.func @omp_cancel_taskgroup() -> () {
omp.taskgroup {
omp.task {
// CHECK: omp.cancel cancellation_construct_type(taskgroup)
omp.cancel cancellation_construct_type(taskgroup)
// CHECK: omp.terminator
omp.terminator
}
// CHECK: omp.terminator
omp.terminator
}
return
}

func.func @omp_cancel_parallel_nested(%if_cond : i1) -> () {
omp.parallel {
scf.if %if_cond {
Expand Down Expand Up @@ -2243,6 +2257,22 @@ func.func @omp_cancel_sections_nested(%if_cond : i1) -> () {
return
}

func.func @omp_cancel_taskgroup_nested(%if_cond : i1) -> () {
omp.taskgroup {
omp.task {
scf.if %if_cond {
// CHECK: omp.cancel cancellation_construct_type(taskgroup)
omp.cancel cancellation_construct_type(taskgroup)
}
// CHECK: omp.terminator
omp.terminator
}
// CHECK: omp.terminator
omp.terminator
}
return
}

func.func @omp_cancellationpoint_parallel() -> () {
omp.parallel {
// CHECK: omp.cancellation_point cancellation_construct_type(parallel)
Expand Down Expand Up @@ -2283,6 +2313,22 @@ func.func @omp_cancellationpoint_sections() -> () {
return
}

func.func @omp_cancellationpoint_taskgroup() -> () {
omp.taskgroup {
omp.task {
// CHECK: omp.cancellation_point cancellation_construct_type(taskgroup)
omp.cancellation_point cancellation_construct_type(taskgroup)
// CHECK: omp.cancel cancellation_construct_type(taskgroup)
omp.cancel cancellation_construct_type(taskgroup)
// CHECK: omp.terminator
omp.terminator
}
// CHECK: omp.terminator
omp.terminator
}
return
}

func.func @omp_cancellationpoint_parallel_nested(%if_cond : i1) -> () {
omp.parallel {
scf.if %if_cond {
Expand Down Expand Up @@ -2323,6 +2369,21 @@ func.func @omp_cancellationpoint_sections_nested(%if_cond : i1) -> () {
return
}

func.func @omp_cancellationpoint_taskgroup_nested(%if_cond : i1) -> () {
omp.taskgroup {
omp.task {
scf.if %if_cond {
// CHECK: omp.cancellation_point cancellation_construct_type(taskgroup)
omp.cancellation_point cancellation_construct_type(taskgroup)
}
omp.terminator
}
// CHECK: omp.terminator
omp.terminator
}
return
}

// CHECK-LABEL: @omp_taskgroup_no_tasks
func.func @omp_taskgroup_no_tasks() -> () {

Expand Down
Loading