[flang-commits] [flang] bbd214d - [flang][openacc] Lower acc declare device_resident for module variable
Valentin Clement via flang-commits
flang-commits at lists.llvm.org
Thu Jul 27 13:01:26 PDT 2023
Author: Valentin Clement
Date: 2023-07-27T13:01:22-07:00
New Revision: bbd214d997c71226fd10211766b2207faf989701
URL: https://github.com/llvm/llvm-project/commit/bbd214d997c71226fd10211766b2207faf989701
DIFF: https://github.com/llvm/llvm-project/commit/bbd214d997c71226fd10211766b2207faf989701.diff
LOG: [flang][openacc] Lower acc declare device_resident for module variable
This patch adds support to lower the device_resident clause on OpenACC
declare construct in module declaration.
Depends on D156457
Reviewed By: razvanlupusoru
Differential Revision: https://reviews.llvm.org/D156463
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 1acd0e294ce199..7db109f8acbbb2 100644
--- a/flang/lib/Lower/OpenACC.cpp
+++ b/flang/lib/Lower/OpenACC.cpp
@@ -2434,6 +2434,13 @@ static void genACC(Fortran::lower::AbstractConverter &converter,
Fortran::parser::AccDataModifier::Modifier::ReadOnly,
mlir::acc::DataClause::acc_copyin,
mlir::acc::DataClause::acc_copyin_readonly);
+ } else if (const auto *deviceResidentClause =
+ std::get_if<Fortran::parser::AccClause::DeviceResident>(
+ &clause.u)) {
+ genGlobalCtors<mlir::acc::DeclareDeviceResidentOp,
+ mlir::acc::DeclareDeviceResidentOp>(
+ converter, modBuilder, deviceResidentClause->v,
+ mlir::acc::DataClause::acc_declare_device_resident);
} else {
TODO(clauseLocation, "OpenACC declare clause");
}
diff --git a/flang/test/Lower/OpenACC/acc-declare.f90 b/flang/test/Lower/OpenACC/acc-declare.f90
index db6d5af7243721..0a234d262e84a6 100644
--- a/flang/test/Lower/OpenACC/acc-declare.f90
+++ b/flang/test/Lower/OpenACC/acc-declare.f90
@@ -55,3 +55,18 @@ module acc_declare_copyin_test
! CHECK: acc.declare_enter dataOperands(%[[COPYIN]] : !fir.ref<!fir.array<100000xf32>>)
! CHECK: acc.terminator
! CHECK: }
+
+module acc_declare_device_resident_test
+ integer, parameter :: n = 5000
+ integer, dimension(n) :: data1
+ !$acc declare device_resident(data1)
+end module
+
+! CHECK-LABEL: fir.global @_QMacc_declare_device_resident_testEdata1 {acc.declare = #acc.declare<dataClause = acc_declare_device_resident>} : !fir.array<5000xi32>
+
+! CHECK-LABEL: acc.global_ctor @_QMacc_declare_device_resident_testEdata1_acc_ctor {
+! CHECK: %[[GLOBAL_ADDR:.*]] = fir.address_of(@_QMacc_declare_device_resident_testEdata1) {acc.declare = #acc.declare<dataClause = acc_declare_device_resident>} : !fir.ref<!fir.array<5000xi32>>
+! CHECK: %[[DEVICERESIDENT:.*]] = acc.declare_device_resident varPtr(%0 : !fir.ref<!fir.array<5000xi32>>) -> !fir.ref<!fir.array<5000xi32>> {name = "data1"}
+! CHECK: acc.declare_enter dataOperands(%[[DEVICERESIDENT]] : !fir.ref<!fir.array<5000xi32>>)
+! CHECK: acc.terminator
+! CHECK: }
More information about the flang-commits
mailing list