[flang-commits] [flang] 66546d9 - [flang][openacc] Lower gang dim to MLIR
Valentin Clement via flang-commits
flang-commits at lists.llvm.org
Tue Jun 13 23:20:48 PDT 2023
Author: Valentin Clement
Date: 2023-06-13T23:20:41-07:00
New Revision: 66546d94fc6a3207a4f4df298e19c5aae04d0388
URL: https://github.com/llvm/llvm-project/commit/66546d94fc6a3207a4f4df298e19c5aae04d0388
DIFF: https://github.com/llvm/llvm-project/commit/66546d94fc6a3207a4f4df298e19c5aae04d0388.diff
LOG: [flang][openacc] Lower gang dim to MLIR
Lower gang dim from the parse tree to the new MLIR
representation.
Depends on D151972
Reviewed By: razvanlupusoru, jeanPerier
Differential Revision: https://reviews.llvm.org/D151973
Added:
Modified:
flang/lib/Lower/OpenACC.cpp
flang/test/Lower/OpenACC/acc-loop.f90
Removed:
################################################################################
diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp
index b4d40cccc8208..aad6dca8575f8 100644
--- a/flang/lib/Lower/OpenACC.cpp
+++ b/flang/lib/Lower/OpenACC.cpp
@@ -790,7 +790,6 @@ createLoopOp(Fortran::lower::AbstractConverter &converter,
} else if (const auto *staticArg =
std::get_if<Fortran::parser::AccGangArg::Static>(
&gangArg.u)) {
-
const Fortran::parser::AccSizeExpr &sizeExpr = staticArg->v;
if (sizeExpr.v) {
gangStatic = fir::getBase(converter.genExprValue(
@@ -801,6 +800,11 @@ createLoopOp(Fortran::lower::AbstractConverter &converter,
gangStatic = builder.createIntegerConstant(
clauseLocation, builder.getIndexType(), starCst);
}
+ } else if (const auto *dim =
+ std::get_if<Fortran::parser::AccGangArg::Dim>(
+ &gangArg.u)) {
+ gangDim = fir::getBase(converter.genExprValue(
+ *Fortran::semantics::GetExpr(dim->v), stmtCtx));
}
}
}
diff --git a/flang/test/Lower/OpenACC/acc-loop.f90 b/flang/test/Lower/OpenACC/acc-loop.f90
index 5b84763e32d7b..bd4d36d8dc012 100644
--- a/flang/test/Lower/OpenACC/acc-loop.f90
+++ b/flang/test/Lower/OpenACC/acc-loop.f90
@@ -14,6 +14,7 @@ program acc_loop
real, dimension(n) :: a, b
real, dimension(n, n) :: c, d
integer :: gangNum = 8
+ integer :: gangDim = 1
integer :: gangStatic = 8
integer :: vectorLength = 128
integer, parameter :: tileSize = 2
@@ -283,4 +284,25 @@ program acc_loop
! CHECK: acc.yield
! CHECK-NEXT: }{{$}}
+ !$acc loop gang(dim: gangDim, static: gangStatic)
+ DO i = 1, n
+ a(i) = b(i)
+ END DO
+
+!CHECK: acc.loop gang(dim=%{{.*}}, static=%{{.*}} : i32) {
+!CHECK: fir.do_loop
+!CHECK: acc.yield
+!CHECK-NEXT: }{{$}}
+
+ !$acc loop gang(dim: 1)
+ DO i = 1, n
+ a(i) = b(i)
+ END DO
+
+!CHECK: [[GANGDIM1:%.*]] = arith.constant 1 : i32
+!CHECK-NEXT: acc.loop gang(dim=[[GANGDIM1]] : i32) {
+!CHECK: fir.do_loop
+!CHECK: acc.yield
+!CHECK-NEXT: }{{$}}
+
end program
More information about the flang-commits
mailing list