[flang-commits] [flang] 0700099 - [flang][openacc] Add lowering support for deviceptr clause on OpenACC declare
Valentin Clement via flang-commits
flang-commits at lists.llvm.org
Wed Aug 2 21:04:27 PDT 2023
Author: Valentin Clement
Date: 2023-08-02T21:04:21-07:00
New Revision: 07000998e4d606072b826baaaad620ae8e9909bd
URL: https://github.com/llvm/llvm-project/commit/07000998e4d606072b826baaaad620ae8e9909bd
DIFF: https://github.com/llvm/llvm-project/commit/07000998e4d606072b826baaaad620ae8e9909bd.diff
LOG: [flang][openacc] Add lowering support for deviceptr clause on OpenACC declare
Lower the deviceptr clause for the OpenACC declare directive.
Reviewed By: razvanlupusoru
Differential Revision: https://reviews.llvm.org/D156828
Added:
Modified:
flang/lib/Lower/OpenACC.cpp
flang/test/Lower/OpenACC/acc-declare.f90
Removed:
################################################################################
diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp
index 7ab6468320ee28..c9fe64e0eabc2a 100644
--- a/flang/lib/Lower/OpenACC.cpp
+++ b/flang/lib/Lower/OpenACC.cpp
@@ -2458,6 +2458,13 @@ genDeclareInFunction(Fortran::lower::AbstractConverter &converter,
/*structured=*/true, /*setDeclareAttr=*/true);
copyoutEntryOperands.append(dataClauseOperands.begin() + crtDataStart,
dataClauseOperands.end());
+ } else if (const auto *devicePtrClause =
+ std::get_if<Fortran::parser::AccClause::Deviceptr>(
+ &clause.u)) {
+ genDataOperandOperations<mlir::acc::DevicePtrOp>(
+ devicePtrClause->v, converter, semanticsContext, stmtCtx,
+ dataClauseOperands, mlir::acc::DataClause::acc_deviceptr,
+ /*structured=*/true);
} else {
mlir::Location clauseLocation = converter.genLocation(clause.source);
TODO(clauseLocation, "clause on declare directive");
diff --git a/flang/test/Lower/OpenACC/acc-declare.f90 b/flang/test/Lower/OpenACC/acc-declare.f90
index 971b0a14613e94..bf873971a40509 100644
--- a/flang/test/Lower/OpenACC/acc-declare.f90
+++ b/flang/test/Lower/OpenACC/acc-declare.f90
@@ -173,4 +173,20 @@ subroutine acc_declare_copyout()
! CHECK: acc.copyout accPtr(%[[CREATE]] : !fir.ref<!fir.array<100xi32>>) bounds(%{{.*}}) to varPtr(%[[A]] : !fir.ref<!fir.array<100xi32>>) {name = "a"}
! CHECK: return
+ subroutine acc_declare_deviceptr(a)
+ integer :: a(100), i
+ !$acc declare deviceptr(a)
+
+ do i = 1, 100
+ a(i) = i
+ end do
+ end subroutine
+
+! CHECK-LABEL: func.func @_QMacc_declarePacc_declare_deviceptr(
+! CHECK-SAME: %[[ARG0:.*]]: !fir.ref<!fir.array<100xi32>> {fir.bindc_name = "a"}) {
+! CHECK: %[[DEVICEPTR:.*]] = acc.deviceptr varPtr(%[[ARG0]] : !fir.ref<!fir.array<100xi32>>) bounds(%{{.*}}) -> !fir.ref<!fir.array<100xi32>> {name = "a"}
+! CHECK: acc.declare_enter dataOperands(%[[DEVICEPTR]] : !fir.ref<!fir.array<100xi32>>)
+! CHECK: %{{.*}}:2 = fir.do_loop %{{.*}} = %{{.*}} to %{{.*}} step %{{.*}} iter_args(%arg{{.*}} = %{{.*}}) -> (index, i32)
+! CHECK-NOT: acc.declare_exit
+
end module
More information about the flang-commits
mailing list