[flang-commits] [flang] f631a10 - [flang][openacc][NFC] Split global acc declare and function/subroutine declare
Valentin Clement via flang-commits
flang-commits at lists.llvm.org
Fri Aug 18 09:29:37 PDT 2023
Author: Valentin Clement
Date: 2023-08-18T09:29:33-07:00
New Revision: f631a10ac364ba39a396cb823ca1ca5eff4ad8b3
URL: https://github.com/llvm/llvm-project/commit/f631a10ac364ba39a396cb823ca1ca5eff4ad8b3
DIFF: https://github.com/llvm/llvm-project/commit/f631a10ac364ba39a396cb823ca1ca5eff4ad8b3.diff
LOG: [flang][openacc][NFC] Split global acc declare and function/subroutine declare
Split the tests for declare in module specification and the declare in
function/subroutine specificatons. Since the lowering is specific to the
location of the declare it will make it easier to update these files.
This also remove the duplicate parts shared by the FIR vs HLFIR tests.
Reviewed By: razvanlupusoru
Differential Revision: https://reviews.llvm.org/D158222
Added:
flang/test/Lower/OpenACC/acc-declare-globals.f90
Modified:
flang/test/Lower/OpenACC/HLFIR/acc-declare.f90
flang/test/Lower/OpenACC/acc-declare.f90
Removed:
################################################################################
diff --git a/flang/test/Lower/OpenACC/HLFIR/acc-declare.f90 b/flang/test/Lower/OpenACC/HLFIR/acc-declare.f90
index cf37230aed779d..139513f07ec035 100644
--- a/flang/test/Lower/OpenACC/HLFIR/acc-declare.f90
+++ b/flang/test/Lower/OpenACC/HLFIR/acc-declare.f90
@@ -1,75 +1,9 @@
-! This test checks lowering of OpenACC declare directive.
+! This test checks lowering of OpenACC declare directive in function and
+! subroutine specification parts.
! RUN: bbc -fopenacc -emit-hlfir %s -o - | FileCheck %s --check-prefixes=HLFIR,ALL
! RUN: bbc -fopenacc -emit-fir -hlfir %s -o - | FileCheck %s --check-prefixes=FIR,ALL
-module acc_declare_test
- integer, parameter :: n = 100000
- real, dimension(n) :: data1
- !$acc declare create(data1)
-end module
-
-! ALL-LABEL: fir.global @_QMacc_declare_testEdata1 {acc.declare = #acc.declare<dataClause = acc_create>} : !fir.array<100000xf32>
-
-! ALL-LABEL: acc.global_ctor @_QMacc_declare_testEdata1_acc_ctor {
-! ALL: %[[GLOBAL_ADDR:.*]] = fir.address_of(@_QMacc_declare_testEdata1) {acc.declare = #acc.declare<dataClause = acc_create>} : !fir.ref<!fir.array<100000xf32>>
-! ALL: %[[CREATE:.*]] = acc.create varPtr(%[[GLOBAL_ADDR]] : !fir.ref<!fir.array<100000xf32>>) -> !fir.ref<!fir.array<100000xf32>> {name = "data1", structured = false}
-! ALL: acc.declare_enter dataOperands(%[[CREATE]] : !fir.ref<!fir.array<100000xf32>>)
-! ALL: acc.terminator
-! ALL: }
-
-! ALL-LABEL: acc.global_dtor @_QMacc_declare_testEdata1_acc_dtor {
-! ALL: %[[GLOBAL_ADDR:.*]] = fir.address_of(@_QMacc_declare_testEdata1) {acc.declare = #acc.declare<dataClause = acc_create>} : !fir.ref<!fir.array<100000xf32>>
-! ALL: %[[DEVICEPTR:.*]] = acc.getdeviceptr varPtr(%[[GLOBAL_ADDR]] : !fir.ref<!fir.array<100000xf32>>) -> !fir.ref<!fir.array<100000xf32>> {dataClause = #acc<data_clause acc_create>, name = "data1", structured = false}
-! ALL: acc.declare_exit dataOperands(%[[DEVICEPTR]] : !fir.ref<!fir.array<100000xf32>>)
-! ALL: acc.delete accPtr(%[[DEVICEPTR]] : !fir.ref<!fir.array<100000xf32>>) {dataClause = #acc<data_clause acc_create>, name = "data1", structured = false}
-! ALL: acc.terminator
-! ALL: }
-
-module acc_declare_copyin_test
- integer, parameter :: n = 100000
- real, dimension(n) :: data1
- !$acc declare copyin(data1)
-end module
-
-
-! ALL-LABEL: acc.global_ctor @_QMacc_declare_copyin_testEdata1_acc_ctor {
-! ALL: %[[GLOBAL_ADDR:.*]] = fir.address_of(@_QMacc_declare_copyin_testEdata1) {acc.declare = #acc.declare<dataClause = acc_copyin>} : !fir.ref<!fir.array<100000xf32>>
-! ALL: %[[COPYIN:.*]] = acc.copyin varPtr(%[[GLOBAL_ADDR]] : !fir.ref<!fir.array<100000xf32>>) -> !fir.ref<!fir.array<100000xf32>> {name = "data1", structured = false}
-! ALL: acc.declare_enter dataOperands(%[[COPYIN]] : !fir.ref<!fir.array<100000xf32>>)
-! ALL: acc.terminator
-! ALL: }
-
-module acc_declare_device_resident_test
- integer, parameter :: n = 5000
- integer, dimension(n) :: data1
- !$acc declare device_resident(data1)
-end module
-
-! ALL-LABEL: fir.global @_QMacc_declare_device_resident_testEdata1 {acc.declare = #acc.declare<dataClause = acc_declare_device_resident>} : !fir.array<5000xi32>
-
-! ALL-LABEL: acc.global_ctor @_QMacc_declare_device_resident_testEdata1_acc_ctor {
-! ALL: %[[GLOBAL_ADDR:.*]] = fir.address_of(@_QMacc_declare_device_resident_testEdata1) {acc.declare = #acc.declare<dataClause = acc_declare_device_resident>} : !fir.ref<!fir.array<5000xi32>>
-! ALL: %[[DEVICERESIDENT:.*]] = acc.declare_device_resident varPtr(%0 : !fir.ref<!fir.array<5000xi32>>) -> !fir.ref<!fir.array<5000xi32>> {name = "data1", structured = false}
-! ALL: acc.declare_enter dataOperands(%[[DEVICERESIDENT]] : !fir.ref<!fir.array<5000xi32>>)
-! ALL: acc.terminator
-! ALL: }
-
-module acc_declare_device_link_test
- integer, parameter :: n = 5000
- integer, dimension(n) :: data1
- !$acc declare link(data1)
-end module
-
-! ALL-LABEL: fir.global @_QMacc_declare_device_link_testEdata1 {acc.declare = #acc.declare<dataClause = acc_declare_link>} : !fir.array<5000xi32> {
-
-! ALL-LABEL: acc.global_ctor @_QMacc_declare_device_link_testEdata1_acc_ctor {
-! ALL: %[[GLOBAL_ADDR:.*]] = fir.address_of(@_QMacc_declare_device_link_testEdata1) {acc.declare = #acc.declare<dataClause = acc_declare_link>} : !fir.ref<!fir.array<5000xi32>>
-! ALL: %[[LINK:.*]] = acc.declare_link varPtr(%[[GLOBAL_ADDR]] : !fir.ref<!fir.array<5000xi32>>) -> !fir.ref<!fir.array<5000xi32>> {name = "data1", structured = false}
-! ALL: acc.declare_enter dataOperands(%[[LINK]] : !fir.ref<!fir.array<5000xi32>>)
-! ALL: acc.terminator
-! ALL: }
-
module acc_declare
contains
diff --git a/flang/test/Lower/OpenACC/acc-declare-globals.f90 b/flang/test/Lower/OpenACC/acc-declare-globals.f90
new file mode 100644
index 00000000000000..a8930b53662f6a
--- /dev/null
+++ b/flang/test/Lower/OpenACC/acc-declare-globals.f90
@@ -0,0 +1,78 @@
+! This test checks lowering of OpenACC declare directive in module specification
+! part.
+
+! RUN: bbc -fopenacc -emit-fir %s -o - | FileCheck %s
+
+module acc_declare_test
+ integer, parameter :: n = 100000
+ real, dimension(n) :: data1
+ !$acc declare create(data1)
+end module
+
+! CHECK-LABEL: fir.global @_QMacc_declare_testEdata1 {acc.declare = #acc.declare<dataClause = acc_create>} : !fir.array<100000xf32>
+
+! CHECK-LABEL: acc.global_ctor @_QMacc_declare_testEdata1_acc_ctor {
+! CHECK: %[[GLOBAL_ADDR:.*]] = fir.address_of(@_QMacc_declare_testEdata1) {acc.declare = #acc.declare<dataClause = acc_create>} : !fir.ref<!fir.array<100000xf32>>
+! CHECK: %[[CREATE:.*]] = acc.create varPtr(%[[GLOBAL_ADDR]] : !fir.ref<!fir.array<100000xf32>>) -> !fir.ref<!fir.array<100000xf32>> {name = "data1", structured = false}
+! CHECK: acc.declare_enter dataOperands(%[[CREATE]] : !fir.ref<!fir.array<100000xf32>>)
+! CHECK: acc.terminator
+! CHECK: }
+
+! CHECK-LABEL: acc.global_dtor @_QMacc_declare_testEdata1_acc_dtor {
+! CHECK: %[[GLOBAL_ADDR:.*]] = fir.address_of(@_QMacc_declare_testEdata1) {acc.declare = #acc.declare<dataClause = acc_create>} : !fir.ref<!fir.array<100000xf32>>
+! CHECK: %[[DEVICEPTR:.*]] = acc.getdeviceptr varPtr(%[[GLOBAL_ADDR]] : !fir.ref<!fir.array<100000xf32>>) -> !fir.ref<!fir.array<100000xf32>> {dataClause = #acc<data_clause acc_create>, name = "data1", structured = false}
+! CHECK: acc.declare_exit dataOperands(%[[DEVICEPTR]] : !fir.ref<!fir.array<100000xf32>>)
+! CHECK: acc.delete accPtr(%[[DEVICEPTR]] : !fir.ref<!fir.array<100000xf32>>) {dataClause = #acc<data_clause acc_create>, name = "data1", structured = false}
+! CHECK: acc.terminator
+! CHECK: }
+
+module acc_declare_copyin_test
+ integer, parameter :: n = 100000
+ real, dimension(n) :: data1
+ !$acc declare copyin(data1)
+end module
+
+! CHECK-LABEL: acc.global_ctor @_QMacc_declare_copyin_testEdata1_acc_ctor {
+! CHECK: %[[GLOBAL_ADDR:.*]] = fir.address_of(@_QMacc_declare_copyin_testEdata1) {acc.declare = #acc.declare<dataClause = acc_copyin>} : !fir.ref<!fir.array<100000xf32>>
+! CHECK: %[[COPYIN:.*]] = acc.copyin varPtr(%[[GLOBAL_ADDR]] : !fir.ref<!fir.array<100000xf32>>) -> !fir.ref<!fir.array<100000xf32>> {name = "data1", structured = false}
+! 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", structured = false}
+! CHECK: acc.declare_enter dataOperands(%[[DEVICERESIDENT]] : !fir.ref<!fir.array<5000xi32>>)
+! CHECK: acc.terminator
+! CHECK: }
+
+! CHECK-LABEL: acc.global_dtor @_QMacc_declare_device_resident_testEdata1_acc_dtor {
+! 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: %[[DEVPTR:.*]] = acc.getdeviceptr varPtr(%[[GLOBAL_ADDR]] : !fir.ref<!fir.array<5000xi32>>) -> !fir.ref<!fir.array<5000xi32>> {dataClause = #acc<data_clause acc_declare_device_resident>, name = "data1", structured = false}
+! CHECK: acc.declare_exit dataOperands(%[[DEVICEPTR]] : !fir.ref<!fir.array<5000xi32>>)
+! CHECK: acc.delete accPtr(%[[DEVICEPTR]] : !fir.ref<!fir.array<5000xi32>>) {dataClause = #acc<data_clause acc_declare_device_resident>, name = "data1", structured = false}
+! CHECK: acc.terminator
+! CHECK: }
+
+module acc_declare_device_link_test
+ integer, parameter :: n = 5000
+ integer, dimension(n) :: data1
+ !$acc declare link(data1)
+end module
+
+! CHECK-LABEL: fir.global @_QMacc_declare_device_link_testEdata1 {acc.declare = #acc.declare<dataClause = acc_declare_link>} : !fir.array<5000xi32> {
+
+! CHECK-LABEL: acc.global_ctor @_QMacc_declare_device_link_testEdata1_acc_ctor {
+! CHECK: %[[GLOBAL_ADDR:.*]] = fir.address_of(@_QMacc_declare_device_link_testEdata1) {acc.declare = #acc.declare<dataClause = acc_declare_link>} : !fir.ref<!fir.array<5000xi32>>
+! CHECK: %[[LINK:.*]] = acc.declare_link varPtr(%[[GLOBAL_ADDR]] : !fir.ref<!fir.array<5000xi32>>) -> !fir.ref<!fir.array<5000xi32>> {name = "data1", structured = false}
+! CHECK: acc.declare_enter dataOperands(%[[LINK]] : !fir.ref<!fir.array<5000xi32>>)
+! CHECK: acc.terminator
+! CHECK: }
diff --git a/flang/test/Lower/OpenACC/acc-declare.f90 b/flang/test/Lower/OpenACC/acc-declare.f90
index 3687f0a910868e..c5ee882943d3b6 100644
--- a/flang/test/Lower/OpenACC/acc-declare.f90
+++ b/flang/test/Lower/OpenACC/acc-declare.f90
@@ -1,82 +1,8 @@
-! This test checks lowering of OpenACC declare directive.
+! This test checks lowering of OpenACC declare directive in subroutine and
+! function specification parts.
! RUN: bbc -fopenacc -emit-fir %s -o - | FileCheck %s
-module acc_declare_test
- integer, parameter :: n = 100000
- real, dimension(n) :: data1
- !$acc declare create(data1)
-end module
-
-! CHECK-LABEL: fir.global @_QMacc_declare_testEdata1 {acc.declare = #acc.declare<dataClause = acc_create>} : !fir.array<100000xf32>
-
-! CHECK-LABEL: acc.global_ctor @_QMacc_declare_testEdata1_acc_ctor {
-! CHECK: %[[GLOBAL_ADDR:.*]] = fir.address_of(@_QMacc_declare_testEdata1) {acc.declare = #acc.declare<dataClause = acc_create>} : !fir.ref<!fir.array<100000xf32>>
-! CHECK: %[[CREATE:.*]] = acc.create varPtr(%[[GLOBAL_ADDR]] : !fir.ref<!fir.array<100000xf32>>) -> !fir.ref<!fir.array<100000xf32>> {name = "data1", structured = false}
-! CHECK: acc.declare_enter dataOperands(%[[CREATE]] : !fir.ref<!fir.array<100000xf32>>)
-! CHECK: acc.terminator
-! CHECK: }
-
-! CHECK-LABEL: acc.global_dtor @_QMacc_declare_testEdata1_acc_dtor {
-! CHECK: %[[GLOBAL_ADDR:.*]] = fir.address_of(@_QMacc_declare_testEdata1) {acc.declare = #acc.declare<dataClause = acc_create>} : !fir.ref<!fir.array<100000xf32>>
-! CHECK: %[[DEVICEPTR:.*]] = acc.getdeviceptr varPtr(%[[GLOBAL_ADDR]] : !fir.ref<!fir.array<100000xf32>>) -> !fir.ref<!fir.array<100000xf32>> {dataClause = #acc<data_clause acc_create>, name = "data1", structured = false}
-! CHECK: acc.declare_exit dataOperands(%[[DEVICEPTR]] : !fir.ref<!fir.array<100000xf32>>)
-! CHECK: acc.delete accPtr(%[[DEVICEPTR]] : !fir.ref<!fir.array<100000xf32>>) {dataClause = #acc<data_clause acc_create>, name = "data1", structured = false}
-! CHECK: acc.terminator
-! CHECK: }
-
-module acc_declare_copyin_test
- integer, parameter :: n = 100000
- real, dimension(n) :: data1
- !$acc declare copyin(data1)
-end module
-
-
-! CHECK-LABEL: acc.global_ctor @_QMacc_declare_copyin_testEdata1_acc_ctor {
-! CHECK: %[[GLOBAL_ADDR:.*]] = fir.address_of(@_QMacc_declare_copyin_testEdata1) {acc.declare = #acc.declare<dataClause = acc_copyin>} : !fir.ref<!fir.array<100000xf32>>
-! CHECK: %[[COPYIN:.*]] = acc.copyin varPtr(%[[GLOBAL_ADDR]] : !fir.ref<!fir.array<100000xf32>>) -> !fir.ref<!fir.array<100000xf32>> {name = "data1", structured = false}
-! 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", structured = false}
-! CHECK: acc.declare_enter dataOperands(%[[DEVICERESIDENT]] : !fir.ref<!fir.array<5000xi32>>)
-! CHECK: acc.terminator
-! CHECK: }
-
-! CHECK-LABEL: acc.global_dtor @_QMacc_declare_device_resident_testEdata1_acc_dtor {
-! 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: %[[DEVPTR:.*]] = acc.getdeviceptr varPtr(%[[GLOBAL_ADDR]] : !fir.ref<!fir.array<5000xi32>>) -> !fir.ref<!fir.array<5000xi32>> {dataClause = #acc<data_clause acc_declare_device_resident>, name = "data1", structured = false}
-! CHECK: acc.declare_exit dataOperands(%[[DEVICEPTR]] : !fir.ref<!fir.array<5000xi32>>)
-! CHECK: acc.delete accPtr(%[[DEVICEPTR]] : !fir.ref<!fir.array<5000xi32>>) {dataClause = #acc<data_clause acc_declare_device_resident>, name = "data1", structured = false}
-! CHECK: acc.terminator
-! CHECK: }
-
-module acc_declare_device_link_test
- integer, parameter :: n = 5000
- integer, dimension(n) :: data1
- !$acc declare link(data1)
-end module
-
-! CHECK-LABEL: fir.global @_QMacc_declare_device_link_testEdata1 {acc.declare = #acc.declare<dataClause = acc_declare_link>} : !fir.array<5000xi32> {
-
-! CHECK-LABEL: acc.global_ctor @_QMacc_declare_device_link_testEdata1_acc_ctor {
-! CHECK: %[[GLOBAL_ADDR:.*]] = fir.address_of(@_QMacc_declare_device_link_testEdata1) {acc.declare = #acc.declare<dataClause = acc_declare_link>} : !fir.ref<!fir.array<5000xi32>>
-! CHECK: %[[LINK:.*]] = acc.declare_link varPtr(%[[GLOBAL_ADDR]] : !fir.ref<!fir.array<5000xi32>>) -> !fir.ref<!fir.array<5000xi32>> {name = "data1", structured = false}
-! CHECK: acc.declare_enter dataOperands(%[[LINK]] : !fir.ref<!fir.array<5000xi32>>)
-! CHECK: acc.terminator
-! CHECK: }
-
module acc_declare
contains
More information about the flang-commits
mailing list