From be5ac66643279a9803053ebb26118559ab630222 Mon Sep 17 00:00:00 2001 From: Valentin Clement Date: Mon, 24 Jul 2023 09:34:00 -0700 Subject: [PATCH] [flang][openacc] Keep original array size in reduction init region with slice Keep the original array size when materializing the private copy. Depends on D155882 Reviewed By: razvanlupusoru Differential Revision: https://reviews.llvm.org/D155893 --- flang/lib/Lower/OpenACC.cpp | 4 ++-- flang/test/Lower/OpenACC/acc-reduction.f90 | 32 ++---------------------------- 2 files changed, 4 insertions(+), 32 deletions(-) diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp index 3d20ef5..1a39dc7 100644 --- a/flang/lib/Lower/OpenACC.cpp +++ b/flang/lib/Lower/OpenACC.cpp @@ -982,10 +982,10 @@ genReductions(const Fortran::parser::AccObjectListWithReduction &objectList, !bounds.empty())) TODO(operandLocation, "reduction with unsupported type"); - mlir::Type retTy = getTypeFromBounds(bounds, baseAddr.getType()); auto op = createDataEntryOp( builder, operandLocation, baseAddr, asFortran, bounds, - /*structured=*/true, mlir::acc::DataClause::acc_reduction, retTy); + /*structured=*/true, mlir::acc::DataClause::acc_reduction, + baseAddr.getType()); mlir::Type ty = op.getAccPtr().getType(); std::string recipeName = fir::getTypeAsString( ty, converter.getKindMap(), diff --git a/flang/test/Lower/OpenACC/acc-reduction.f90 b/flang/test/Lower/OpenACC/acc-reduction.f90 index 21cdae7..068b526 100644 --- a/flang/test/Lower/OpenACC/acc-reduction.f90 +++ b/flang/test/Lower/OpenACC/acc-reduction.f90 @@ -2,34 +2,6 @@ ! RUN: bbc -fopenacc -emit-fir %s -o - | FileCheck %s -! CHECK-LABEL: acc.reduction.recipe @reduction_add_ref_10xi32 : !fir.ref> reduction_operator init { -! CHECK: ^bb0(%{{.*}}: !fir.ref>): -! CHECK: %[[INIT:.*]] = arith.constant 0 : i32 -! CHECK: %[[ALLOCA:.*]] = fir.alloca !fir.array<10xi32> -! CHECK: %[[LB:.*]] = arith.constant 0 : index -! CHECK: %[[UB:.*]] = arith.constant 9 : index -! CHECK: %[[STEP:.*]] = arith.constant 1 : index -! CHECK: fir.do_loop %[[IV:.*]] = %[[LB]] to %[[UB]] step %[[STEP]] { -! CHECK: %[[COORD:.*]] = fir.coordinate_of %0, %[[IV]] : (!fir.ref>, index) -> !fir.ref -! CHECK: fir.store %[[INIT]] to %[[COORD]] : !fir.ref -! CHECK: } -! CHECK: acc.yield %[[ALLOCA]] : !fir.ref> -! CHECK: } combiner { -! CHECK: ^bb0(%[[ARG0:.*]]: !fir.ref>, %[[ARG1:.*]]: !fir.ref>): -! CHECK: %[[LB:.*]] = arith.constant 0 : index -! CHECK: %[[UB:.*]] = arith.constant 9 : index -! CHECK: %[[STEP:.*]] = arith.constant 1 : index -! CHECK: fir.do_loop %[[IV:.*]] = %[[LB]] to %[[UB]] step %[[STEP]] { -! CHECK: %[[COORD1:.*]] = fir.coordinate_of %[[ARG0]], %[[IV]] : (!fir.ref>, index) -> !fir.ref -! CHECK: %[[COORD2:.*]] = fir.coordinate_of %[[ARG1]], %[[IV]] : (!fir.ref>, index) -> !fir.ref -! CHECK: %[[LOAD1:.*]] = fir.load %[[COORD1]] : !fir.ref -! CHECK: %[[LOAD2:.*]] = fir.load %[[COORD2]] : !fir.ref -! CHECK: %[[COMBINED:.*]] = arith.addi %[[LOAD1]], %[[LOAD2]] : i32 -! CHECK: fir.store %[[COMBINED]] to %[[COORD1]] : !fir.ref -! CHECK: } -! CHECK: acc.yield %[[ARG0]] : !fir.ref> -! CHECK: } - ! CHECK-LABEL: acc.reduction.recipe @reduction_mul_ref_z32 : !fir.ref> reduction_operator init { ! CHECK: ^bb0(%{{.*}}: !fir.ref>): ! CHECK: %[[REAL:.*]] = arith.constant 1.000000e+00 : f32 @@ -950,5 +922,5 @@ end subroutine ! CHECK: %[[LB:.*]] = arith.constant 10 : index ! CHECK: %[[UB:.*]] = arith.constant 19 : index ! CHECK: %[[BOUND:.*]] = acc.bounds lowerbound(%[[LB]] : index) upperbound(%[[UB]] : index) stride(%[[C1]] : index) startIdx(%[[C1]] : index) -! CHECK: %[[RED:.*]] = acc.reduction varPtr(%[[ARG0]] : !fir.ref>) bounds(%[[BOUND]]) -> !fir.ref> {name = "a(11:20)"} -! CHECK: acc.parallel reduction(@reduction_add_ref_10xi32 -> %[[RED]] : !fir.ref>) +! CHECK: %[[RED:.*]] = acc.reduction varPtr(%[[ARG0]] : !fir.ref>) bounds(%[[BOUND]]) -> !fir.ref> {name = "a(11:20)"} +! CHECK: acc.parallel reduction(@reduction_add_ref_100xi32 -> %[[RED]] : !fir.ref>) -- 2.7.4