Skip to content

Commit e1d8d5d

Browse files
Stylie777git-crd
authored andcommitted
[Flang][OpenMP] Add Lowering support for Collapse with Taskloop (llvm#166791)
Support 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 4471d8b commit e1d8d5d

File tree

4 files changed

+49
-17
lines changed

4 files changed

+49
-17
lines changed

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,8 +1781,6 @@ static void genTaskloopClauses(
17811781
cp.processPriority(stmtCtx, clauseOps);
17821782
cp.processReduction(loc, clauseOps, reductionSyms);
17831783
cp.processUntied(clauseOps);
1784-
1785-
cp.processTODO<clause::Collapse>(loc, llvm::omp::Directive::OMPD_taskloop);
17861784
}
17871785

17881786
static void genTaskwaitClauses(lower::AbstractConverter &converter,

flang/test/Lower/OpenMP/Todo/taskloop-collapse.f90

Lines changed: 0 additions & 15 deletions
This file was deleted.
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
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
! When lowering Taskloop, it is possible for the TileSizes clause to be lowered, but this is not a supported clause.
2+
! We should make sure that any use of Tilesizes with Taskloop is correctly rejected by the Semantics.
3+
! RUN: %python %S/../test_errors.py %s %flang -fopenmp
4+
5+
subroutine test
6+
integer :: i, sum
7+
8+
!ERROR: TILE cannot follow TASKLOOP
9+
!ERROR: SIZES clause is not allowed on the TASKLOOP directive
10+
!$omp taskloop tile sizes(2)
11+
do i=1,10
12+
sum = sum + i
13+
end do
14+
!$omp end taskloop
15+
end subroutine

0 commit comments

Comments
 (0)