Skip to content

Commit caabd5e

Browse files
committed
[Flang][OpenMP] Add Lowering support for Collapse with Taskloop
Supprot for lowering collapse already exists within `genLoopNestClauses`, which is called when lowering taskloop. However, the TODO message still included the Collapse clause, so it was not activated. By removing this, it enables lowering of the Collapse clause in taskloop.
1 parent a928c61 commit caabd5e

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1773,7 +1773,7 @@ static void genTaskloopClauses(lower::AbstractConverter &converter,
17731773
cp.processGrainsize(stmtCtx, clauseOps);
17741774
cp.processNumTasks(stmtCtx, clauseOps);
17751775

1776-
cp.processTODO<clause::Allocate, clause::Collapse, clause::Default,
1776+
cp.processTODO<clause::Allocate, clause::Default,
17771777
clause::Final, clause::If, clause::InReduction,
17781778
clause::Lastprivate, clause::Mergeable, clause::Nogroup,
17791779
clause::Priority, clause::Reduction, clause::Shared,
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
! Test the collapse clause when being used with the taskloop construct
2+
! RUN: bbc -emit-hlfir -fopenmp -fopenmp-version=45 %s -o - 2>&1 | FileCheck %s
3+
! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=45 %s -o - 2>&1 | FileCheck %s
4+
5+
! CHECK-LABEL: omp.private
6+
! CHECK-SAME: {type = private} @[[J_PRIVATE:.*]] : i32
7+
! CHECK-LABEL: omp.private
8+
! CHECK-SAME: {type = private} @[[I_PRIVATE:.*]] : i32
9+
! CHECK-LABEL: omp.private
10+
! CHECK-SAME: {type = firstprivate} @[[SUM_FIRSTPRIVATE:.*]] : i32 copy
11+
12+
! CHECK-LABEL: func.func @_QPtest()
13+
! CHECK: %[[ALLOCA_I:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFtestEi"}
14+
! CHECK: %[[DECLARE_I:.*]]:2 = hlfir.declare %1 {uniq_name = "_QFtestEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
15+
! CHECK: %[[ALLOCA_J:.*]] = fir.alloca i32 {bindc_name = "j", uniq_name = "_QFtestEj"}
16+
! CHECK: %[[DECLARE_J:.*]]:2 = hlfir.declare %3 {uniq_name = "_QFtestEj"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
17+
! CHECK: %[[ALLOCA_SUM:.*]] = fir.alloca i32 {bindc_name = "sum", uniq_name = "_QFtestEsum"}
18+
! CHECK: %[[DECLARE_SUM:.*]]:2 = hlfir.declare %5 {uniq_name = "_QFtestEsum"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
19+
20+
subroutine test()
21+
integer :: i, j, sum
22+
23+
!$omp taskloop collapse(2)
24+
! CHECK-LABEL: omp.taskloop
25+
! CHECK-SAME: private(@_QFtestEsum_firstprivate_i32 %[[DECLARE_SUM]]#0 -> %arg0, @_QFtestEi_private_i32 %[[DECLARE_I]]#0 -> %arg1, @_QFtestEj_private_i32 %[[DECLARE_J]]#0 -> %arg2 : !fir.ref<i32>, !fir.ref<i32>, !fir.ref<i32>)
26+
! CHECK-LABEL: omp.loop_nest
27+
! CHECK-SAME: (%arg3, %arg4) : i32 = (%c1_i32, %c1_i32_1) to (%c10_i32, %c5_i32) inclusive step (%c1_i32_0, %c1_i32_2) collapse(2)
28+
do i = 1, 10
29+
do j = 1, 5
30+
sum = sum + i + j
31+
end do
32+
end do
33+
!$omp end taskloop
34+
end subroutine

0 commit comments

Comments
 (0)