aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg
diff options
context:
space:
mode:
authorKwok Cheung Yeung <kcyeung@baylibre.com>2024-02-15 20:59:39 +0000
committerKwok Cheung Yeung <kcyeung@baylibre.com>2024-02-15 21:04:53 +0000
commit451bb5866021cc854cd972396c6bc4923eb14d39 (patch)
tree25eed3b7bd77d7ce4eb6d9d71468ca95d1c14887 /gcc/testsuite/gfortran.dg
parent617bd59c659dcf6e5391409a2e9f64f75e905a96 (diff)
downloadgcc-451bb5866021cc854cd972396c6bc4923eb14d39.zip
gcc-451bb5866021cc854cd972396c6bc4923eb14d39.tar.gz
gcc-451bb5866021cc854cd972396c6bc4923eb14d39.tar.bz2
openmp, fortran: Add Fortran support for indirect clause on the declare target directive
2024-02-15 Kwok Cheung Yeung <kcyeung@baylibre.com> gcc/fortran/ * dump-parse-tree.cc (show_attr): Handle omp_declare_target_indirect attribute. * f95-lang.cc (gfc_gnu_attributes): Add entry for 'omp declare target indirect'. * gfortran.h (symbol_attribute): Add omp_declare_target_indirect field. (struct gfc_omp_clauses): Add indirect field. * openmp.cc (omp_mask2): Add OMP_CLAUSE_INDIRECT. (gfc_match_omp_clauses): Match indirect clause. (OMP_DECLARE_TARGET_CLAUSES): Add OMP_CLAUSE_INDIRECT. (gfc_match_omp_declare_target): Check omp_device_type and apply omp_declare_target_indirect attribute to symbol if indirect clause active. Show warning if there are only device_type and/or indirect clauses on the directive. * trans-decl.cc (add_attributes_to_decl): Add 'omp declare target indirect' attribute if symbol has indirect attribute set. gcc/testsuite/ * gfortran.dg/gomp/declare-target-4.f90 (f1): Update expected warning. * gfortran.dg/gomp/declare-target-indirect-1.f90: New. * gfortran.dg/gomp/declare-target-indirect-2.f90: New. libgomp/ * testsuite/libgomp.fortran/declare-target-indirect-1.f90: New. * testsuite/libgomp.fortran/declare-target-indirect-2.f90: New. * testsuite/libgomp.fortran/declare-target-indirect-3.f90: New.
Diffstat (limited to 'gcc/testsuite/gfortran.dg')
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/declare-target-4.f902
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/declare-target-indirect-1.f9062
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/declare-target-indirect-2.f9025
3 files changed, 88 insertions, 1 deletions
diff --git a/gcc/testsuite/gfortran.dg/gomp/declare-target-4.f90 b/gcc/testsuite/gfortran.dg/gomp/declare-target-4.f90
index 4f5de4b..55534d8 100644
--- a/gcc/testsuite/gfortran.dg/gomp/declare-target-4.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/declare-target-4.f90
@@ -2,7 +2,7 @@
! { dg-additional-options "-fdump-tree-original" }
subroutine f1
- !$omp declare target device_type (any) ! { dg-warning "OMP DECLARE TARGET directive at .1. with only DEVICE_TYPE clause is ignored" }
+ !$omp declare target device_type (any) ! { dg-warning "OMP DECLARE TARGET directive at .1. with only DEVICE_TYPE or INDIRECT clauses is ignored" }
end subroutine
subroutine f2
diff --git a/gcc/testsuite/gfortran.dg/gomp/declare-target-indirect-1.f90 b/gcc/testsuite/gfortran.dg/gomp/declare-target-indirect-1.f90
new file mode 100644
index 0000000..504c1a2
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/declare-target-indirect-1.f90
@@ -0,0 +1,62 @@
+! { dg-do compile }
+! { dg-options "-fopenmp" }
+
+module m
+ integer :: a
+ integer, parameter :: X = 1
+ integer, parameter :: Y = 2
+
+ ! Indirect on a variable should have no effect.
+ integer :: z
+ !$omp declare target to (z) indirect
+contains
+ subroutine sub1
+ !$omp declare target indirect to (sub1)
+ end subroutine
+
+ subroutine sub2
+ !$omp declare target enter (sub2) indirect (.true.)
+ end subroutine
+
+ subroutine sub3
+ !$omp declare target to (sub3) indirect (.false.)
+ end subroutine
+
+ subroutine sub4
+ !$omp declare target to (sub4) indirect (1) ! { dg-error "INDIRECT clause at .1. requires a constant logical expression" }
+ end subroutine
+
+ ! Compile-time non-constant expressions are not allowed.
+ subroutine sub5
+ !$omp declare target indirect (a > 0) to (sub5) ! { dg-error "INDIRECT clause at .1. requires a constant logical expression" }
+ end subroutine
+
+ ! Compile-time constant expressions are permissible.
+ subroutine sub6
+ !$omp declare target indirect (X .eq. Y) to (sub6)
+ end subroutine
+
+ subroutine sub7
+ !$omp declare target indirect ! { dg-warning "OMP DECLARE TARGET directive at .1. with only DEVICE_TYPE or INDIRECT clauses is ignored" }
+ end subroutine
+
+ subroutine sub8
+ !$omp declare target indirect (.true.) indirect (.false.) to (sub8) ! { dg-error "Duplicated .indirect. clause at .1." }
+ end subroutine
+
+ subroutine sub9
+ !$omp declare target to (sub9) indirect ("abs") ! { dg-error "INDIRECT clause at .1. requires a constant logical expression" }
+ end subroutine
+
+ subroutine sub10
+ !$omp declare target to (sub10) indirect (5.5) ! { dg-error "INDIRECT clause at .1. requires a constant logical expression" }
+ end subroutine
+
+ subroutine sub11
+ !$omp declare target indirect (.true.) device_type (host) enter (sub11) ! { dg-error "DEVICE_TYPE must be ANY when used with INDIRECT at .1." }
+ end subroutine
+
+ subroutine sub12
+ !$omp declare target indirect (.false.) device_type (nohost) enter (sub12)
+ end subroutine
+end module
diff --git a/gcc/testsuite/gfortran.dg/gomp/declare-target-indirect-2.f90 b/gcc/testsuite/gfortran.dg/gomp/declare-target-indirect-2.f90
new file mode 100644
index 0000000..f6b3ae1
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/declare-target-indirect-2.f90
@@ -0,0 +1,25 @@
+! { dg-do compile }
+! { dg-options "-fopenmp -fdump-tree-gimple" }
+
+module m
+contains
+ subroutine sub1
+ !$omp declare target indirect enter (sub1)
+ end subroutine
+ ! { dg-final { scan-tree-dump "__attribute__\\\(\\\(omp declare target, omp declare target indirect\\\)\\\)\\\n.*\\\nvoid sub1" "gimple" } }
+
+ subroutine sub2
+ !$omp declare target indirect (.false.) to (sub2)
+ end subroutine
+ ! { dg-final { scan-tree-dump "__attribute__\\\(\\\(omp declare target\\\)\\\)\\\n.*\\\nvoid sub2" "gimple" } }
+
+ subroutine sub3
+ !$omp declare target indirect (.true.) to (sub3)
+ end subroutine
+ ! { dg-final { scan-tree-dump "__attribute__\\\(\\\(omp declare target, omp declare target indirect\\\)\\\)\\\n.*\\\nvoid sub3" "gimple" } }
+
+ subroutine sub4
+ !$omp declare target indirect (.false.) enter (sub4)
+ end subroutine
+ ! { dg-final { scan-tree-dump "__attribute__\\\(\\\(omp declare target\\\)\\\)\\\n.*\\\nvoid sub4" "gimple" } }
+end module