Skip to content

Commit cc8c746

Browse files
[NFC][Flang] Add simd collapse test case
Flang supports lowering collapse clause to MLIR for worksharing loops and simd loops. Simd collapse clause is represented in MLIR code as a simd-loop having a list of indices, bounds and steps where the size of the list is equal to the collapse value. Support for simd collapse clause was added by several patches: https://reviews.llvm.org/D118065 -> basic support for simd-loop in MLIR. Loop collapsing is done in the same way as for worksharing loops: https://reviews.llvm.org/D105706 https://reviews.llvm.org/D125282 -> support for lowering simd clause from Fortran into MLIR https://reviews.llvm.org/D125302 -> lowering collapse clause from Fortran to MLIR. Lowering collapse clause is done before simd-specific function is called. https://reviews.llvm.org/D128338 -> modified the MLIR representation of collapse clause. Removed collapse keyword in OpenMP MLIR dialect. Use loop list to represent collapse clause. This loop list is created by changes from patch: https://reviews.llvm.org/D125302 and it is passed to function responsible for lowering of simd directive which was implemented in patch: https://reviews.llvm.org/D125282 Reviewed By: kiranchandramohan Differential Revision: https://reviews.llvm.org/D132023 Signed-off-by: Dominik Adamski <[email protected]>
1 parent 6a9f79e commit cc8c746

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

flang/test/Lower/OpenMP/simd.f90

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,26 @@ subroutine simdloop_with_simdlen_clause_from_expr_from_param(n, threshold)
8989
end do
9090
!$OMP END SIMD
9191
end subroutine
92+
93+
!CHECK-LABEL: func @_QPsimdloop_with_collapse_clause
94+
subroutine simdloop_with_collapse_clause(n)
95+
integer :: i, j, n
96+
integer :: A(n,n)
97+
! CHECK: %[[LOWER_I:.*]] = arith.constant 1 : i32
98+
! CHECK: %[[UPPER_I:.*]] = fir.load %[[PARAM_ARG:.*]] : !fir.ref<i32>
99+
! CHECK: %[[STEP_I:.*]] = arith.constant 1 : i32
100+
! CHECK: %[[LOWER_J:.*]] = arith.constant 1 : i32
101+
! CHECK: %[[UPPER_J:.*]] = fir.load %[[PARAM_ARG:.*]] : !fir.ref<i32>
102+
! CHECK: %[[STEP_J:.*]] = arith.constant 1 : i32
103+
! CHECK: omp.simdloop for (%[[ARG_0:.*]], %[[ARG_1:.*]]) : i32 = (
104+
! CHECK-SAME: %[[LOWER_I]], %[[LOWER_J]]) to (
105+
! CHECK-SAME: %[[UPPER_I]], %[[UPPER_J]]) inclusive step (
106+
! CHECK-SAME: %[[STEP_I]], %[[STEP_J]]) {
107+
!$OMP SIMD COLLAPSE(2)
108+
do i = 1, n
109+
do j = 1, n
110+
A(i,j) = i + j
111+
end do
112+
end do
113+
!$OMP END SIMD
114+
end subroutine

0 commit comments

Comments
 (0)