Skip to content

[Flang][OpenMP] Add LLVM translation support for UNTIED clause in Task #115283

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

Merged
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
1 change: 1 addition & 0 deletions flang/lib/Lower/OpenMP/OpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2867,6 +2867,7 @@ static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
!std::holds_alternative<clause::UseDevicePtr>(clause.u) &&
!std::holds_alternative<clause::InReduction>(clause.u) &&
!std::holds_alternative<clause::Mergeable>(clause.u) &&
!std::holds_alternative<clause::Untied>(clause.u) &&
!std::holds_alternative<clause::TaskReduction>(clause.u) &&
!std::holds_alternative<clause::Detach>(clause.u)) {
std::string name =
Expand Down
13 changes: 0 additions & 13 deletions flang/test/Lower/OpenMP/Todo/task_untied.f90

This file was deleted.

17 changes: 17 additions & 0 deletions flang/test/Lower/OpenMP/task.f90
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,27 @@ subroutine task_multiple_clauses()
!$omp end task
end subroutine task_multiple_clauses

!===============================================================================
! `mergeable` clause
!===============================================================================

subroutine task_mergeable()
!CHECK: omp.task mergeable {
!CHECK: omp.terminator
!CHECK: }
!$omp task mergeable
!$omp end task
end subroutine

!===============================================================================
! `untied` clause
!===============================================================================

!CHECK-LABEL: func.func @_QPomp_task_untied() {
subroutine omp_task_untied()
!CHECK: omp.task untied {
!$omp task untied
call foo()
!CHECK: omp.terminator
!$omp end task
end subroutine omp_task_untied
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ static LogicalResult checkImplementationStatus(Operation &op) {
checkAllocate(op, result);
checkInReduction(op, result);
checkPriority(op, result);
checkUntied(op, result);
})
.Case([&](omp::TaskgroupOp op) {
checkAllocate(op, result);
Expand All @@ -268,6 +267,10 @@ static LogicalResult checkImplementationStatus(Operation &op) {
checkDepend(op, result);
checkNowait(op, result);
})
.Case([&](omp::TaskloopOp op) {
// TODO: Add other clauses check
checkUntied(op, result);
})
.Case([&](omp::WsloopOp op) {
checkAllocate(op, result);
checkLinear(op, result);
Expand Down
12 changes: 12 additions & 0 deletions mlir/test/Target/LLVMIR/openmp-llvm.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -3020,6 +3020,18 @@ module attributes {omp.is_target_device = true} {

// -----

llvm.func @omp_task_untied() {
// The third argument is 0: which signifies the united task
// CHECK: {{.*}} = call ptr @__kmpc_omp_task_alloc(ptr @1, i32 %{{.*}}, i32 0,
// CHECK-SAME: i64 40, i64 0, ptr @{{.*}})
omp.task untied {
omp.terminator
}
llvm.return
}

// -----

// Third argument is 5: essentially (4 || 1)
// signifying this task is TIED and MERGEABLE

Expand Down
24 changes: 13 additions & 11 deletions mlir/test/Target/LLVMIR/openmp-todo.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -440,17 +440,6 @@ llvm.func @task_priority(%x : i32) {

// -----

llvm.func @task_untied() {
// expected-error@below {{not yet implemented: Unhandled clause untied in omp.task operation}}
// expected-error@below {{LLVM Translation failed for operation: omp.task}}
omp.task untied {
omp.terminator
}
llvm.return
}

// -----

llvm.func @taskgroup_allocate(%x : !llvm.ptr) {
// expected-error@below {{not yet implemented: Unhandled clause allocate in omp.taskgroup operation}}
// expected-error@below {{LLVM Translation failed for operation: omp.taskgroup}}
Expand Down Expand Up @@ -503,6 +492,19 @@ llvm.func @taskloop(%lb : i32, %ub : i32, %step : i32) {

// -----

llvm.func @taskloop_untied(%lb : i32, %ub : i32, %step : i32) {
// expected-error@below {{not yet implemented: omp.taskloop}}
// expected-error@below {{LLVM Translation failed for operation: omp.taskloop}}
omp.taskloop untied {
omp.loop_nest (%iv) : i32 = (%lb) to (%ub) step (%step) {
omp.yield
}
}
llvm.return
}

// -----

llvm.func @taskwait_depend(%x: !llvm.ptr) {
// expected-error@below {{not yet implemented: Unhandled clause depend in omp.taskwait operation}}
// expected-error@below {{LLVM Translation failed for operation: omp.taskwait}}
Expand Down
Loading