[flang-commits] [flang] cc8c746 - [NFC][Flang] Add simd collapse test case
Dominik Adamski via flang-commits
flang-commits at lists.llvm.org
Wed Aug 17 05:48:23 PDT 2022
Author: Dominik Adamski
Date: 2022-08-17T07:42:22-05:00
New Revision: cc8c746f8df5274ac20486bd62b1183c0583ea6a
URL: https://github.com/llvm/llvm-project/commit/cc8c746f8df5274ac20486bd62b1183c0583ea6a
DIFF: https://github.com/llvm/llvm-project/commit/cc8c746f8df5274ac20486bd62b1183c0583ea6a.diff
LOG: [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 <dominik.adamski at amd.com>
Added:
Modified:
flang/test/Lower/OpenMP/simd.f90
Removed:
################################################################################
diff --git a/flang/test/Lower/OpenMP/simd.f90 b/flang/test/Lower/OpenMP/simd.f90
index c1adf6e70df14..1be8863ca1f71 100644
--- a/flang/test/Lower/OpenMP/simd.f90
+++ b/flang/test/Lower/OpenMP/simd.f90
@@ -89,3 +89,26 @@ subroutine simdloop_with_simdlen_clause_from_expr_from_param(n, threshold)
end do
!$OMP END SIMD
end subroutine
+
+!CHECK-LABEL: func @_QPsimdloop_with_collapse_clause
+subroutine simdloop_with_collapse_clause(n)
+integer :: i, j, n
+integer :: A(n,n)
+! CHECK: %[[LOWER_I:.*]] = arith.constant 1 : i32
+! CHECK: %[[UPPER_I:.*]] = fir.load %[[PARAM_ARG:.*]] : !fir.ref<i32>
+! CHECK: %[[STEP_I:.*]] = arith.constant 1 : i32
+! CHECK: %[[LOWER_J:.*]] = arith.constant 1 : i32
+! CHECK: %[[UPPER_J:.*]] = fir.load %[[PARAM_ARG:.*]] : !fir.ref<i32>
+! CHECK: %[[STEP_J:.*]] = arith.constant 1 : i32
+! CHECK: omp.simdloop for (%[[ARG_0:.*]], %[[ARG_1:.*]]) : i32 = (
+! CHECK-SAME: %[[LOWER_I]], %[[LOWER_J]]) to (
+! CHECK-SAME: %[[UPPER_I]], %[[UPPER_J]]) inclusive step (
+! CHECK-SAME: %[[STEP_I]], %[[STEP_J]]) {
+ !$OMP SIMD COLLAPSE(2)
+ do i = 1, n
+ do j = 1, n
+ A(i,j) = i + j
+ end do
+ end do
+ !$OMP END SIMD
+end subroutine
More information about the flang-commits
mailing list