Skip to content

Commit b5d84b3

Browse files
[Flang][OpenMP] Add LLVM translation support for UNTIED clause in Task
Implementation details: The UNTIED clause is recognized by setting the flag=0 for the default case or performing logical OR to flag if other clauses are specified, and this flag is passed as an argument to the `__kmpc_omp_task_alloc` runtime call.
1 parent 1469d82 commit b5d84b3

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2844,6 +2844,7 @@ static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
28442844
!std::holds_alternative<clause::UseDevicePtr>(clause.u) &&
28452845
!std::holds_alternative<clause::InReduction>(clause.u) &&
28462846
!std::holds_alternative<clause::Mergeable>(clause.u) &&
2847+
!std::holds_alternative<clause::Untied>(clause.u) &&
28472848
!std::holds_alternative<clause::TaskReduction>(clause.u)) {
28482849
TODO(clauseLocation, "OpenMP Block construct clause");
28492850
}

flang/test/Lower/OpenMP/Todo/task_untied.f90

Lines changed: 0 additions & 13 deletions
This file was deleted.

flang/test/Lower/OpenMP/task.f90

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,3 +245,16 @@ subroutine task_multiple_clauses()
245245
!CHECK: omp.terminator
246246
!$omp end task
247247
end subroutine task_multiple_clauses
248+
249+
!===============================================================================
250+
! `untied` clause
251+
!===============================================================================
252+
253+
!CHECK-LABEL: func.func @_QPomp_task_untied() {
254+
subroutine omp_task_untied()
255+
!CHECK: omp.task untied {
256+
!$omp task untied
257+
call foo()
258+
!CHECK: omp.terminator
259+
!$omp end task
260+
end subroutine omp_task_untied

mlir/test/Target/LLVMIR/openmp-llvm.mlir

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3003,6 +3003,17 @@ module attributes {omp.is_target_device = true} {
30033003

30043004
// -----
30053005

3006+
llvm.func @omp_task_untied() {
3007+
// The third argument is 0: which signifies the united task
3008+
// CHECK: {{.*}} = call ptr @__kmpc_omp_task_alloc(ptr @1, i32 %{{.*}}, i32 0, i64 40, i64 0, ptr @{{.*}})
3009+
omp.task untied {
3010+
omp.terminator
3011+
}
3012+
llvm.return
3013+
}
3014+
3015+
// -----
3016+
30063017
llvm.func external @foo_before() -> ()
30073018
llvm.func external @foo() -> ()
30083019
llvm.func external @foo_after() -> ()

0 commit comments

Comments
 (0)