Skip to content

Commit faf9ac0

Browse files
authored
[Flang][MLIR][OpenMP] Add MLIR lowering support for taskloop clauses. (#165851)
This patch add MLIR lowering support for the following taskloop clauses: 1. Default clause 2. Shared clause 3. Allocate clause 4. Final clause 5. If clause 6. Mergeable clause 7. Priority clause 8. Untied clause
1 parent cf91088 commit faf9ac0

File tree

7 files changed

+329
-9
lines changed

7 files changed

+329
-9
lines changed

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,14 +1769,18 @@ static void genTaskloopClauses(lower::AbstractConverter &converter,
17691769
mlir::omp::TaskloopOperands &clauseOps) {
17701770

17711771
ClauseProcessor cp(converter, semaCtx, clauses);
1772+
cp.processAllocate(clauseOps);
1773+
cp.processFinal(stmtCtx, clauseOps);
17721774
cp.processGrainsize(stmtCtx, clauseOps);
1775+
cp.processIf(llvm::omp::Directive::OMPD_taskloop, clauseOps);
1776+
cp.processMergeable(clauseOps);
17731777
cp.processNumTasks(stmtCtx, clauseOps);
1778+
cp.processPriority(stmtCtx, clauseOps);
1779+
cp.processUntied(clauseOps);
17741780

1775-
cp.processTODO<clause::Allocate, clause::Collapse, clause::Default,
1776-
clause::Final, clause::If, clause::InReduction,
1777-
clause::Lastprivate, clause::Mergeable, clause::Nogroup,
1778-
clause::Priority, clause::Reduction, clause::Shared,
1779-
clause::Untied>(loc, llvm::omp::Directive::OMPD_taskloop);
1781+
cp.processTODO<clause::Collapse, clause::InReduction, clause::Lastprivate,
1782+
clause::Nogroup, clause::Reduction>(
1783+
loc, llvm::omp::Directive::OMPD_taskloop);
17801784
}
17811785

17821786
static void genTaskwaitClauses(lower::AbstractConverter &converter,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
! RUN: %not_todo_cmd bbc -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s
2+
! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s
3+
4+
! CHECK: not yet implemented: Unhandled clause COLLAPSE in TASKLOOP construct
5+
subroutine omp_taskloop_collapse()
6+
integer x
7+
x = 0
8+
!$omp taskloop collapse(2)
9+
do i = 1, 100
10+
do j = 1, 100
11+
x = x + 1
12+
end do
13+
end do
14+
!$omp end taskloop
15+
end subroutine omp_taskloop_collapse
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
! RUN: %not_todo_cmd bbc -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s
2+
! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s
3+
4+
! CHECK: not yet implemented: Unhandled clause LASTPRIVATE in TASKLOOP construct
5+
subroutine omp_taskloop_lastprivate()
6+
integer x
7+
x = 0
8+
!$omp taskloop lastprivate(x)
9+
do i = 1, 100
10+
x = x + 1
11+
end do
12+
!$omp end taskloop
13+
end subroutine omp_taskloop_lastprivate
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
! RUN: %not_todo_cmd bbc -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s
2+
! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s
3+
4+
! CHECK: not yet implemented: Unhandled clause NOGROUP in TASKLOOP construct
5+
subroutine omp_taskloop_nogroup()
6+
integer x
7+
x = 0
8+
!$omp taskloop nogroup
9+
do i = 1, 100
10+
x = x + 1
11+
end do
12+
!$omp end taskloop
13+
end subroutine omp_taskloop_nogroup

flang/test/Lower/OpenMP/if-clause.f90

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ program main
1212
! - PARALLEL SECTIONS
1313
! - PARALLEL WORKSHARE
1414
! - TARGET UPDATE
15-
! - TASKLOOP
1615
! - TASKLOOP SIMD
1716

1817
! ----------------------------------------------------------------------------
@@ -1580,4 +1579,29 @@ program main
15801579
!$omp teams if(teams: .true.)
15811580
i = 1
15821581
!$omp end teams
1582+
1583+
! ----------------------------------------------------------------------------
1584+
! TASKLOOP
1585+
! ----------------------------------------------------------------------------
1586+
1587+
! CHECK: omp.taskloop
1588+
! CHECK-NOT: if({{.*}})
1589+
!$omp taskloop
1590+
do i = 1, 10
1591+
end do
1592+
!$omp end taskloop
1593+
1594+
! CHECK: omp.taskloop
1595+
! CHECK-SAME: if({{.*}})
1596+
!$omp taskloop if(.true.)
1597+
do i = 1, 10
1598+
end do
1599+
!$omp end taskloop
1600+
1601+
! CHECK: omp.taskloop
1602+
! CHECK-SAME: if({{.*}})
1603+
!$omp taskloop if(taskloop: .true.)
1604+
do i = 1, 10
1605+
end do
1606+
!$omp end taskloop
15831607
end program main

flang/test/Lower/OpenMP/implicit-dsa.f90

Lines changed: 127 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,36 @@
55

66
! Privatizers
77

8+
! CHECK-LABEL: omp.private
9+
! CHECK-SAME: {type = private} @[[TASKLOOP_TEST3_I_PRIVATE:.*]] : i32
10+
! CHECK-NOT: copy {
11+
12+
! CHECK-LABEL: omp.private
13+
! CHECK-SAME: {type = firstprivate} @[[TASKLOOP_TEST3_X_FIRSTPRIVATE:.*]] : i32
14+
! CHECK-SAME: copy {
15+
! CHECK: hlfir.assign
16+
17+
! CHECK-LABEL: omp.private
18+
! CHECK-SAME: {type = private} @[[TASKLOOP_TEST2_X_PRIVATE:.*]] : i32
19+
! CHECK-NOT: copy {
20+
21+
! CHECK-LABEL: omp.private
22+
! CHECK-SAME: {type = private} @[[TASKLOOP_TEST2_I_PRIVATE:.*]] : i32
23+
! CHECK-NOT: copy {
24+
25+
! CHECK-LABEL: omp.private
26+
! CHECK-SAME: {type = private} @[[TASKLOOP_TEST1_I_PRIVATE:.*]] : i32
27+
! CHECK-NOT: copy {
28+
29+
! CHECK-LABEL: omp.private
30+
! CHECK-SAME: {type = firstprivate} @[[TASKLOOP_TEST1_X_FIRSTPRIVATE:.*]] : i32
31+
! CHECK-SAME: copy {
32+
! CHECK: hlfir.assign
33+
34+
! CHECK-LABEL: omp.private
35+
! CHECK-SAME: {type = private} @[[TASKLOOP_TEST1_Y_PRIVATE:.*]] : i32
36+
! CHECK-NOT: copy {
37+
838
! CHECK-LABEL: omp.private
939
! CHECK-SAME: {type = firstprivate} @[[TEST7_Y_FIRSTPRIV:.*]] : i32
1040
! CHECK-SAME: copy {
@@ -310,4 +340,100 @@ subroutine implicit_dsa_test7
310340
!$omp end task
311341
end subroutine
312342

313-
! TODO Test taskloop
343+
! Test taskloop
344+
! CHECK-LABEL: func.func @_QPimplicit_dsa_taskloop_test1
345+
! CHECK: %[[ALLOCA_I:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFimplicit_dsa_taskloop_test1Ei"}
346+
! CHECK: %[[DECL_I:.*]]:2 = hlfir.declare %[[ALLOCA_I]] {uniq_name = "_QFimplicit_dsa_taskloop_test1Ei"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
347+
! CHECK: %[[ALLOCA_X:.*]] = fir.alloca i32 {bindc_name = "x", uniq_name = "_QFimplicit_dsa_taskloop_test1Ex"}
348+
! CHECK: %[[DECL_X:.*]]:2 = hlfir.declare %[[ALLOCA_X]] {uniq_name = "_QFimplicit_dsa_taskloop_test1Ex"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
349+
! CHECK: %[[ALLOCA_Y:.*]] = fir.alloca i32 {bindc_name = "y", uniq_name = "_QFimplicit_dsa_taskloop_test1Ey"}
350+
! CHECK: %[[DECL_Y:.*]]:2 = hlfir.declare %[[ALLOCA_Y]] {uniq_name = "_QFimplicit_dsa_taskloop_test1Ey"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
351+
! CHECK: %[[ALLOCA_Z:.*]] = fir.alloca i32 {bindc_name = "z", uniq_name = "_QFimplicit_dsa_taskloop_test1Ez"}
352+
! CHECK: %[[DECL_Z:.*]]:2 = hlfir.declare %[[ALLOCA_Z]] {uniq_name = "_QFimplicit_dsa_taskloop_test1Ez"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
353+
subroutine implicit_dsa_taskloop_test1
354+
integer :: x, y, z
355+
! CHECK: omp.taskloop private(
356+
! CHECK-SAME: @[[TASKLOOP_TEST1_Y_PRIVATE]] %[[DECL_Y]]#0 -> %[[ARG0:.*]], @[[TASKLOOP_TEST1_X_FIRSTPRIVATE]] %[[DECL_X]]#0 -> %[[ARG1:.*]], @[[TASKLOOP_TEST1_I_PRIVATE]] %[[DECL_I]]#0 -> %[[ARG2:.*]] : !fir.ref<i32>, !fir.ref<i32>, !fir.ref<i32>) {
357+
! CHECK: omp.loop_nest (%{{.*}}) : i32 = (%{{.*}}) to (%{{.*}}) inclusive step (%{{.*}}) {
358+
!$omp taskloop private(y) shared(z)
359+
do i = 1, 100
360+
! CHECK: %[[Y_VAL:.*]]:2 = hlfir.declare %[[ARG0]] {uniq_name = "_QFimplicit_dsa_taskloop_test1Ey"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
361+
! CHECK: %[[X_VAL:.*]]:2 = hlfir.declare %[[ARG1]] {uniq_name = "_QFimplicit_dsa_taskloop_test1Ex"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
362+
! CHECK: %[[LOAD_Z:.*]] = fir.load %[[DECL_Z]]#0 : !fir.ref<i32>
363+
x = y + z
364+
! CHECK: hlfir.assign %{{.*}} to %[[X_VAL]]#0 : i32, !fir.ref<i32>
365+
end do
366+
!$omp end taskloop
367+
368+
! CHECK: omp.taskloop private(@[[TASKLOOP_TEST1_I_PRIVATE]] %[[DECL_I]]#0 -> %[[ARG0:.*]] : !fir.ref<i32>) {
369+
!$omp taskloop default(shared)
370+
do i = 1, 100
371+
! CHECK: %[[LOAD_Y:.*]] = fir.load %[[DECL_Y]]#0 : !fir.ref<i32>
372+
! CHECK: %[[LOAD_Z:.*]] = fir.load %[[DECL_Z]]#0 : !fir.ref<i32>
373+
! CHECK: %[[ADD_VAL:.*]] = arith.addi %[[LOAD_Y]], %[[LOAD_Z]] : i32
374+
x = y + z
375+
! CHECK: hlfir.assign %[[ADD_VAL]] to %[[DECL_X]]#0 : i32, !fir.ref<i32>
376+
end do
377+
!$omp end taskloop
378+
end subroutine
379+
380+
! Nested taskloop with implicit shared DSA variables.
381+
! CHECK-LABEL: func @_QPimplicit_dsa_taskloop_test2
382+
! CHECK: %[[I:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFimplicit_dsa_taskloop_test2Ei"}
383+
! CHECK: %[[I_DECL:.*]]:2 = hlfir.declare %[[I]] {uniq_name = "_QFimplicit_dsa_taskloop_test2Ei"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
384+
! CHECK: %[[X:.*]] = fir.alloca i32 {bindc_name = "x", uniq_name = "_QFimplicit_dsa_taskloop_test2Ex"}
385+
! CHECK: %[[X_DECL:.*]]:2 = hlfir.declare %[[X]] {uniq_name = "_QFimplicit_dsa_taskloop_test2Ex"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
386+
subroutine implicit_dsa_taskloop_test2
387+
integer :: x
388+
! CHECK: omp.parallel {
389+
!$omp parallel
390+
! CHECK: omp.taskloop private(@[[TASKLOOP_TEST2_I_PRIVATE]] %[[I_DECL]]#0 -> %[[ARG0:.*]] : !fir.ref<i32>) {
391+
!$omp taskloop
392+
do i = 1, 100
393+
! CHECK: hlfir.assign %{{.*}} to %[[X_DECL]]#0 : i32, !fir.ref<i32>
394+
x = 2
395+
end do
396+
!$omp end taskloop
397+
398+
! CHECK: omp.taskloop private(@[[TASKLOOP_TEST2_X_PRIVATE]] %[[X_DECL]]#0 -> %[[ARG0]], @[[TASKLOOP_TEST2_I_PRIVATE]] %[[I_DECL]]#0 -> %[[ARG1:.*]] : !fir.ref<i32>, !fir.ref<i32>) {
399+
!$omp taskloop private(x)
400+
do i = 1, 10
401+
! CHECK: %[[DECL_PRIV_X:.*]]:2 = hlfir.declare %[[ARG0]] {uniq_name = "_QFimplicit_dsa_taskloop_test2Ex"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
402+
! CHECK: %[[LOAD_X:.*]] = fir.load %[[DECL_PRIV_X]]#0 : !fir.ref<i32>
403+
x = x + 1
404+
! CHECK: hlfir.assign %{{.*}} to %[[DECL_PRIV_X]]#0 : i32, !fir.ref<i32>
405+
end do
406+
!$omp end parallel
407+
408+
end subroutine
409+
410+
! Taskloop with implicit firstprivate DSA variables, enclosed in private context.
411+
412+
! CHECK-LABEL: func @_QPimplicit_dsa_taskloop_test3
413+
! CHECK: %[[I:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFimplicit_dsa_taskloop_test3Ei"}
414+
! CHECK: %[[I_DECL:.*]]:2 = hlfir.declare %[[I]] {uniq_name = "_QFimplicit_dsa_taskloop_test3Ei"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
415+
! CHECK: %[[X:.*]] = fir.alloca i32 {bindc_name = "x", uniq_name = "_QFimplicit_dsa_taskloop_test3Ex"}
416+
! CHECK: %[[X_DECL:.*]]:2 = hlfir.declare %[[X]] {uniq_name = "_QFimplicit_dsa_taskloop_test3Ex"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
417+
! CHECK: %[[Y:.*]] = fir.alloca i32 {bindc_name = "y", uniq_name = "_QFimplicit_dsa_taskloop_test3Ey"}
418+
! CHECK: %[[Y_DECL:.*]]:2 = hlfir.declare %[[Y]] {uniq_name = "_QFimplicit_dsa_taskloop_test3Ey"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
419+
! CHECK: %[[Z:.*]] = fir.alloca i32 {bindc_name = "z", uniq_name = "_QFimplicit_dsa_taskloop_test3Ez"}
420+
! CHECK: %[[Z_DECL:.*]]:2 = hlfir.declare %[[Z]] {uniq_name = "_QFimplicit_dsa_taskloop_test3Ez"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
421+
422+
subroutine implicit_dsa_taskloop_test3
423+
integer :: x, y, z
424+
! CHECK: omp.parallel private(@[[TASKLOOP_TEST3_X_FIRSTPRIVATE]] %[[X_DECL]]#0 -> %[[ARG0:.*]] : !fir.ref<i32>) {
425+
! CHECK: %[[X_PRIV_VAL:.*]]:2 = hlfir.declare %[[ARG0]] {uniq_name = "_QFimplicit_dsa_taskloop_test3Ex"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
426+
!$omp parallel firstprivate(x)
427+
! CHECK: omp.taskloop private(@[[TASKLOOP_TEST3_X_FIRSTPRIVATE]] %[[X_PRIV_VAL]]#0 -> %[[ARG1:.*]], @[[TASKLOOP_TEST3_I_PRIVATE]] %[[I_DECL]]#0 -> %[[ARG2:.*]] : !fir.ref<i32>, !fir.ref<i32>) {
428+
!$omp taskloop
429+
! CHECK: %[[X_VAL:.*]]:2 = hlfir.declare %[[ARG1]] {uniq_name = "_QFimplicit_dsa_taskloop_test3Ex"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
430+
do i = 1, 100
431+
! CHECK: %[[LOAD_Y:.*]] = fir.load %[[Y_DECL]]#0 : !fir.ref<i32>
432+
! CHECK: %[[LOAD_Z:.*]] = fir.load %[[Z_DECL]]#0 : !fir.ref<i32>
433+
x = y + z
434+
! CHECK: hlfir.assign %{{.*}} to %[[X_VAL]]#0 : i32, !fir.ref<i32>
435+
end do
436+
!$omp end taskloop
437+
!$omp end parallel
438+
end subroutine
439+

flang/test/Lower/OpenMP/taskloop.f90

Lines changed: 127 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
1-
! RUN: bbc -emit-hlfir -fopenmp -fopenmp-version=50 -o - %s 2>&1 | FileCheck %s
2-
! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=50 -o - %s 2>&1 | FileCheck %s
1+
! REQUIRES: openmp_runtime
2+
! RUN: bbc -emit-hlfir %openmp_flags -o - %s 2>&1 | FileCheck %s
3+
! RUN: %flang_fc1 -emit-hlfir %openmp_flags -o - %s 2>&1 | FileCheck %s
4+
5+
! CHECK-LABEL: omp.private
6+
! CHECK-SAME: {type = private} @[[OMP_TASKLOOP_UNTIEDEI_PRIVATE_I32:.*]] : i32
7+
8+
! CHECK-LABEL: omp.private
9+
! CHECK-SAME: {type = private} @[[QFTEST_PRIORITYEI_PRIVATE_I32:.*]] : i32
10+
11+
! CHECK-LABEL: omp.private
12+
! CHECK-SAME: {type = private} @[[QFTEST_MERGEABLEEI_PRIVATE_I32:.*]] : i32
13+
14+
! CHECK-LABEL: omp.private
15+
! CHECK-SAME: {type = private} @[[I_PRIVATE_IF_TEST1:.*]] : i32
16+
17+
! CHECK-LABEL: omp.private
18+
! CHECK-SAME: {type = private} @[[I_PRIVATE_FINAL:.*]] : i32
19+
20+
! CHECK-LABEL: omp.private
21+
! CHECK-SAME: {type = private} @[[I_PRIVATE_TEST_ALLOCATE:.*]] : i32
22+
23+
! CHECK-LABEL: omp.private
24+
! CHECK-SAME: {type = private} @[[X_PRIVATE_TEST_ALLOCATE:.*]] : i32
325

426
! CHECK-LABEL: omp.private
527
! CHECK-SAME: {type = private} @[[I_PRIVATE_TEST2:.*]] : i32
@@ -70,3 +92,106 @@ subroutine omp_taskloop_private
7092
! CHECK: }
7193
!$omp end taskloop
7294
end subroutine omp_taskloop_private
95+
96+
!===============================================================================
97+
! `allocate` clause
98+
!===============================================================================
99+
100+
! CHECK-LABEL: func.func @_QPtaskloop_allocate
101+
! CHECK: %[[ALLOCA_I:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFtaskloop_allocateEi"}
102+
! CHECK: %[[DECL_I:.*]]:2 = hlfir.declare %[[ALLOCA_I]] {uniq_name = "_QFtaskloop_allocateEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
103+
! CHECK: %[[ALLOCA_X:.*]] = fir.alloca i32 {bindc_name = "x", uniq_name = "_QFtaskloop_allocateEx"}
104+
! CHECK: %[[DECL_X:.*]]:2 = hlfir.declare %[[ALLOCA_X]] {uniq_name = "_QFtaskloop_allocateEx"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
105+
subroutine taskloop_allocate()
106+
use omp_lib
107+
integer :: x
108+
! CHECK: omp.taskloop allocate(%{{.*}} : i64 -> %[[DECL_X]]#0 : !fir.ref<i32>)
109+
! CHECK-SAME: private(@[[X_PRIVATE_TEST_ALLOCATE]] %[[DECL_X]]#0 -> %[[ARG0:.*]], @[[I_PRIVATE_TEST_ALLOCATE]] %[[DECL_I]]#0 -> %[[ARG1:.*]] : !fir.ref<i32>, !fir.ref<i32>) {
110+
!$omp taskloop allocate(omp_high_bw_mem_alloc: x) private(x)
111+
do i = 1, 100
112+
! CHECK: arith.addi
113+
x = x + 12
114+
! CHECK: omp.yield
115+
end do
116+
!$omp end taskloop
117+
end subroutine taskloop_allocate
118+
119+
!===============================================================================
120+
! `final` clause
121+
!===============================================================================
122+
123+
! CHECK-LABEL: func.func @_QPtaskloop_final
124+
! CHECK: %[[ALLOCA_I:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFtaskloop_finalEi"}
125+
! CHECK: %[[DECL_I:.*]]:2 = hlfir.declare %[[ALLOCA_I]] {uniq_name = "_QFtaskloop_finalEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
126+
subroutine taskloop_final()
127+
! CHECK: omp.taskloop final(%true) private(@[[I_PRIVATE_FINAL]] %[[DECL_I]]#0 -> %[[ARG0:.*]] : !fir.ref<i32>) {
128+
!$omp taskloop final(.true.)
129+
do i = 1, 100
130+
! CHECK: fir.call @_QPfoo()
131+
call foo()
132+
end do
133+
!$omp end taskloop
134+
end subroutine
135+
136+
!===============================================================================
137+
! `if` clause
138+
!===============================================================================
139+
140+
! CHECK-LABEL: func.func @_QPomp_taskloop_if
141+
! CHECK: %[[DECL_BAR:.*]]:2 = hlfir.declare %[[ARG0:.*]] dummy_scope %{{.*}}
142+
! CHECK: %[[ALLOCA_I:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFomp_taskloop_ifEi"}
143+
! CHECK: %[[DECL_I:.*]]:2 = hlfir.declare %[[ALLOCA_I]] {uniq_name = "_QFomp_taskloop_ifEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
144+
! CHECK: %[[LOAD_VAL:.*]] = fir.load %[[DECL_BAR]]#0 : !fir.ref<!fir.logical<4>>
145+
! CHECK: %[[VAL_BAR:.*]] = fir.convert %[[LOAD_VAL]] : (!fir.logical<4>) -> i1
146+
subroutine omp_taskloop_if(bar)
147+
logical, intent(inout) :: bar
148+
!CHECK: omp.taskloop if(%[[VAL_BAR]]) private(@[[I_PRIVATE_IF_TEST1]] %[[DECL_I]]#0 -> %[[ARG1:.*]] : !fir.ref<i32>) {
149+
!$omp taskloop if(bar)
150+
do i = 1, 10
151+
call foo()
152+
end do
153+
!$omp end taskloop
154+
end subroutine omp_taskloop_if
155+
156+
!===============================================================================
157+
! `mergeable` clause
158+
!===============================================================================
159+
160+
! CHECK-LABEL: func.func @_QPtest_mergeable
161+
subroutine test_mergeable
162+
! CHECK: omp.taskloop mergeable
163+
!$omp taskloop mergeable
164+
do i = 1, 10
165+
end do
166+
!$omp end taskloop
167+
end subroutine test_mergeable
168+
169+
!===============================================================================
170+
! `priority` clause
171+
!===============================================================================
172+
173+
! CHECK-LABEL: func.func @_QPtest_priority
174+
! CHECK: %[[VAL1:.*]]:2 = hlfir.declare %[[ARG0:.*]] dummy_scope %{{.*}}
175+
! CHECK: %[[LOAD_VAL:.*]] = fir.load %[[VAL1]]#0 : !fir.ref<i32>
176+
subroutine test_priority(n)
177+
integer, intent(inout) :: n
178+
! CHECK: omp.taskloop priority(%[[LOAD_VAL]] : i32)
179+
!$omp taskloop priority(n)
180+
do i = 1, 10
181+
end do
182+
!$omp end taskloop
183+
end subroutine test_priority
184+
185+
!===============================================================================
186+
! `untied` clause
187+
!===============================================================================
188+
189+
! CHECK-LABEL: func.func @_QPomp_taskloop_untied
190+
subroutine omp_taskloop_untied()
191+
! CHECK: omp.taskloop untied
192+
!$omp taskloop untied
193+
do i = 1, 10
194+
call foo()
195+
end do
196+
!$omp end taskloop
197+
end subroutine

0 commit comments

Comments
 (0)