Skip to content

Commit 68fa9eb

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 f6c51ea commit 68fa9eb

File tree

4 files changed

+30
-13
lines changed

4 files changed

+30
-13
lines changed

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2869,6 +2869,7 @@ static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
28692869
!std::holds_alternative<clause::UseDevicePtr>(clause.u) &&
28702870
!std::holds_alternative<clause::InReduction>(clause.u) &&
28712871
!std::holds_alternative<clause::Mergeable>(clause.u) &&
2872+
!std::holds_alternative<clause::Untied>(clause.u) &&
28722873
!std::holds_alternative<clause::TaskReduction>(clause.u)) {
28732874
std::string name =
28742875
parser::ToUpperCaseLetters(llvm::omp::getOpenMPClauseName(clause.id));

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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,27 @@ subroutine task_multiple_clauses()
235235
!$omp end task
236236
end subroutine task_multiple_clauses
237237

238+
!===============================================================================
239+
! `mergeable` clause
240+
!===============================================================================
241+
238242
subroutine task_mergeable()
239243
!CHECK: omp.task mergeable {
240244
!CHECK: omp.terminator
241245
!CHECK: }
242246
!$omp task mergeable
243247
!$omp end task
244248
end subroutine
249+
250+
!===============================================================================
251+
! `untied` clause
252+
!===============================================================================
253+
254+
!CHECK-LABEL: func.func @_QPomp_task_untied() {
255+
subroutine omp_task_untied()
256+
!CHECK: omp.task untied {
257+
!$omp task untied
258+
call foo()
259+
!CHECK: omp.terminator
260+
!$omp end task
261+
end subroutine omp_task_untied

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3020,6 +3020,18 @@ module attributes {omp.is_target_device = true} {
30203020

30213021
// -----
30223022

3023+
llvm.func @omp_task_untied() {
3024+
// The third argument is 0: which signifies the united task
3025+
// CHECK: {{.*}} = call ptr @__kmpc_omp_task_alloc(ptr @1, i32 %{{.*}}, i32 0,
3026+
// CHECK-SAME: i64 40, i64 0, ptr @{{.*}})
3027+
omp.task untied {
3028+
omp.terminator
3029+
}
3030+
llvm.return
3031+
}
3032+
3033+
// -----
3034+
30233035
// Third argument is 5: essentially (4 || 1)
30243036
// signifying this task is TIED and MERGEABLE
30253037

0 commit comments

Comments
 (0)