aboutsummaryrefslogtreecommitdiff
path: root/libgomp
diff options
context:
space:
mode:
authorJames Norris <jnorris@codesourcery.com>2015-11-22 16:45:38 +0000
committerJames Norris <jnorris@gcc.gnu.org>2015-11-22 16:45:38 +0000
commitdc7a8b4b7ad10f7c001593605051fcd174540a76 (patch)
tree07e91d9f58d420855371941119707e37a4f2c08e /libgomp
parent9030a4d3aa90c1db1a657fe5588c823f0ea73a86 (diff)
downloadgcc-dc7a8b4b7ad10f7c001593605051fcd174540a76.zip
gcc-dc7a8b4b7ad10f7c001593605051fcd174540a76.tar.gz
gcc-dc7a8b4b7ad10f7c001593605051fcd174540a76.tar.bz2
dump-parse-tree.c (show_namespace): Handle declares.
gcc/fortran/ * dump-parse-tree.c (show_namespace): Handle declares. * gfortran.h (struct symbol_attribute): New fields. (enum gfc_omp_map_map): Add OMP_MAP_DEVICE_RESIDENT and OMP_MAP_LINK. (OMP_LIST_LINK): New enum. (struct gfc_oacc_declare): New structure. (gfc_get_oacc_declare): New definition. (struct gfc_namespace): Change type. (enum gfc_exec_op): Add EXEC_OACC_DECLARE. (struct gfc_code): New field. * module.c (enum ab_attribute): Add AB_OACC_DECLARE_CREATE, AB_OACC_DECLARE_COPYIN, AB_OACC_DECLARE_DEVICEPTR, AB_OACC_DECLARE_DEVICE_RESIDENT, AB_OACC_DECLARE_LINK (attr_bits): Add new initializers. (mio_symbol_attribute): Handle new atributes. * openmp.c (gfc_free_oacc_declare_clauses): New function. (gfc_match_oacc_clause_link: Likewise. (OMP_CLAUSE_LINK): New definition. (gfc_match_omp_clauses): Handle OMP_CLAUSE_LINK. (OACC_DECLARE_CLAUSES): Add OMP_CLAUSE_LINK (gfc_match_oacc_declare): Add checking and module handling. (resolve_omp_clauses): Add array initializer. (gfc_resolve_oacc_declare): Reimplement. * parse.c (case_decl): Add ST_OACC_DECLARE. (parse_spec): Remove handling. (parse_progunit): Remove handling. * parse.h (struct gfc_state_data): Change type. * resolve.c (gfc_resolve_blocks): Handle EXEC_OACC_DECLARE. * st.c (gfc_free_statement): Handle EXEC_OACC_DECLARE. * symbol.c (check_conflict): Add conflict checks. (gfc_add_oacc_declare_create, gfc_add_oacc_declare_copyin, gfc_add_oacc_declare_deviceptr, gfc_add_oacc_declare_device_resident): New functions. (gfc_copy_attr): Handle new symbols. * trans-decl.c (add_clause, find_module_oacc_declare_clauses, finish_oacc_declare): New functions. (gfc_generate_function_code): Replace with call. * trans-openmp.c (gfc_trans_oacc_declare): Reimplement. (gfc_trans_oacc_directive): Handle EXEC_OACC_DECLARE. * trans-stmt.c (gfc_trans_block_construct): Replace with call. * trans-stmt.h (gfc_trans_oacc_declare): Remove argument. * trans.c (trans_code): Handle EXEC_OACC_DECLARE. gcc/testsuite * gfortran.dg/goacc/declare-1.f95: Update test. * gfortran.dg/goacc/declare-2.f95: New test. libgomp/ * testsuite/libgomp.oacc-fortran/declare-1.f90: New test. * testsuite/libgomp.oacc-fortran/declare-2.f90: Likewise. * testsuite/libgomp.oacc-fortran/declare-3.f90: Likewise. * testsuite/libgomp.oacc-fortran/declare-4.f90: Likewise. * testsuite/libgomp.oacc-fortran/declare-5.f90: Likewise. Co-Authored-By: Cesar Philippidis <cesar@codesourcery.com> From-SVN: r230722
Diffstat (limited to 'libgomp')
-rw-r--r--libgomp/ChangeLog9
-rw-r--r--libgomp/testsuite/libgomp.oacc-fortran/declare-1.f90248
-rw-r--r--libgomp/testsuite/libgomp.oacc-fortran/declare-2.f9016
-rw-r--r--libgomp/testsuite/libgomp.oacc-fortran/declare-3.f9068
-rw-r--r--libgomp/testsuite/libgomp.oacc-fortran/declare-4.f9029
-rw-r--r--libgomp/testsuite/libgomp.oacc-fortran/declare-5.f9029
6 files changed, 399 insertions, 0 deletions
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index 7de19b0..a083f35 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,3 +1,12 @@
+2015-11-22 James Norris <jnorris@codesourcery.com>
+ Cesar Philippidis <cesar@codesourcery.com>
+
+ * testsuite/libgomp.oacc-fortran/declare-1.f90: New test.
+ * testsuite/libgomp.oacc-fortran/declare-2.f90: Likewise.
+ * testsuite/libgomp.oacc-fortran/declare-3.f90: Likewise.
+ * testsuite/libgomp.oacc-fortran/declare-4.f90: Likewise.
+ * testsuite/libgomp.oacc-fortran/declare-5.f90: Likewise.
+
2015-11-20 Jakub Jelinek <jakub@redhat.com>
PR middle-end/68221
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/declare-1.f90 b/libgomp/testsuite/libgomp.oacc-fortran/declare-1.f90
new file mode 100644
index 0000000..f717d1b
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-fortran/declare-1.f90
@@ -0,0 +1,248 @@
+! { dg-do run { target openacc_nvidia_accel_selected } }
+
+module vars
+ implicit none
+ integer z
+ !$acc declare create (z)
+end module vars
+
+subroutine subr6 (a, d)
+ implicit none
+ integer, parameter :: N = 8
+ integer :: i
+ integer :: a(N)
+ !$acc declare deviceptr (a)
+ integer :: d(N)
+
+ i = 0
+
+ !$acc parallel copy (d)
+ do i = 1, N
+ d(i) = a(i) + a(i)
+ end do
+ !$acc end parallel
+
+end subroutine
+
+subroutine subr5 (a, b, c, d)
+ implicit none
+ integer, parameter :: N = 8
+ integer :: i
+ integer :: a(N)
+ !$acc declare present_or_copyin (a)
+ integer :: b(N)
+ !$acc declare present_or_create (b)
+ integer :: c(N)
+ !$acc declare present_or_copyout (c)
+ integer :: d(N)
+ !$acc declare present_or_copy (d)
+
+ i = 0
+
+ !$acc parallel
+ do i = 1, N
+ b(i) = a(i)
+ c(i) = b(i)
+ d(i) = d(i) + b(i)
+ end do
+ !$acc end parallel
+
+end subroutine
+
+subroutine subr4 (a, b)
+ implicit none
+ integer, parameter :: N = 8
+ integer :: i
+ integer :: a(N)
+ !$acc declare present (a)
+ integer :: b(N)
+ !$acc declare copyout (b)
+
+ i = 0
+
+ !$acc parallel
+ do i = 1, N
+ b(i) = a(i)
+ end do
+ !$acc end parallel
+
+end subroutine
+
+subroutine subr3 (a, c)
+ implicit none
+ integer, parameter :: N = 8
+ integer :: i
+ integer :: a(N)
+ !$acc declare present (a)
+ integer :: c(N)
+ !$acc declare copyin (c)
+
+ i = 0
+
+ !$acc parallel
+ do i = 1, N
+ a(i) = c(i)
+ c(i) = 0
+ end do
+ !$acc end parallel
+
+end subroutine
+
+subroutine subr2 (a, b, c)
+ implicit none
+ integer, parameter :: N = 8
+ integer :: i
+ integer :: a(N)
+ !$acc declare present (a)
+ integer :: b(N)
+ !$acc declare create (b)
+ integer :: c(N)
+ !$acc declare copy (c)
+
+ i = 0
+
+ !$acc parallel
+ do i = 1, N
+ b(i) = a(i)
+ c(i) = b(i) + c(i) + 1
+ end do
+ !$acc end parallel
+
+end subroutine
+
+subroutine subr1 (a)
+ implicit none
+ integer, parameter :: N = 8
+ integer :: i
+ integer :: a(N)
+ !$acc declare present (a)
+
+ i = 0
+
+ !$acc parallel
+ do i = 1, N
+ a(i) = a(i) + 1
+ end do
+ !$acc end parallel
+
+end subroutine
+
+subroutine test (a, e)
+ use openacc
+ implicit none
+ logical :: e
+ integer, parameter :: N = 8
+ integer :: a(N)
+
+ if (acc_is_present (a) .neqv. e) call abort
+
+end subroutine
+
+subroutine subr0 (a, b, c, d)
+ implicit none
+ integer, parameter :: N = 8
+ integer :: a(N)
+ !$acc declare copy (a)
+ integer :: b(N)
+ integer :: c(N)
+ integer :: d(N)
+ integer :: i
+
+ call test (a, .true.)
+ call test (b, .false.)
+ call test (c, .false.)
+
+ call subr1 (a)
+
+ call test (a, .true.)
+ call test (b, .false.)
+ call test (c, .false.)
+
+ call subr2 (a, b, c)
+
+ call test (a, .true.)
+ call test (b, .false.)
+ call test (c, .false.)
+
+ do i = 1, N
+ if (c(i) .ne. 8) call abort
+ end do
+
+ call subr3 (a, c)
+
+ call test (a, .true.)
+ call test (b, .false.)
+ call test (c, .false.)
+
+ do i = 1, N
+ if (a(i) .ne. 2) call abort
+ if (c(i) .ne. 8) call abort
+ end do
+
+ call subr4 (a, b)
+
+ call test (a, .true.)
+ call test (b, .false.)
+ call test (c, .false.)
+
+ do i = 1, N
+ if (b(i) .ne. 8) call abort
+ end do
+
+ call subr5 (a, b, c, d)
+
+ call test (a, .true.)
+ call test (b, .false.)
+ call test (c, .false.)
+ call test (d, .false.)
+
+ do i = 1, N
+ if (c(i) .ne. 8) call abort
+ if (d(i) .ne. 13) call abort
+ end do
+
+ call subr6 (a, d)
+
+ call test (a, .true.)
+ call test (d, .false.)
+
+ do i = 1, N
+ if (d(i) .ne. 16) call abort
+ end do
+
+end subroutine
+
+program main
+ use vars
+ use openacc
+ implicit none
+ integer, parameter :: N = 8
+ integer :: a(N)
+ integer :: b(N)
+ integer :: c(N)
+ integer :: d(N)
+ integer :: i
+
+ a(:) = 2
+ b(:) = 3
+ c(:) = 4
+ d(:) = 5
+
+ if (acc_is_present (z) .neqv. .true.) call abort
+
+ call subr0 (a, b, c, d)
+
+ call test (a, .false.)
+ call test (b, .false.)
+ call test (c, .false.)
+ call test (d, .false.)
+
+ do i = 1, N
+ if (a(i) .ne. 8) call abort
+ if (b(i) .ne. 8) call abort
+ if (c(i) .ne. 8) call abort
+ if (d(i) .ne. 16) call abort
+ end do
+
+
+end program
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/declare-2.f90 b/libgomp/testsuite/libgomp.oacc-fortran/declare-2.f90
new file mode 100644
index 0000000..2aa7907
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-fortran/declare-2.f90
@@ -0,0 +1,16 @@
+! { dg-do run { target openacc_nvidia_accel_selected } }
+
+module globalvars
+ implicit none
+ integer a
+ !$acc declare create (a)
+end module globalvars
+
+program test
+ use globalvars
+ use openacc
+ implicit none
+
+ if (acc_is_present (a) .neqv. .true.) call abort
+
+end program test
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/declare-3.f90 b/libgomp/testsuite/libgomp.oacc-fortran/declare-3.f90
new file mode 100644
index 0000000..3a6b420
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-fortran/declare-3.f90
@@ -0,0 +1,68 @@
+! { dg-do run { target openacc_nvidia_accel_selected } }
+
+module globalvars
+ implicit none
+ real b
+ !$acc declare link (b)
+end module globalvars
+
+program test
+ use openacc
+ use globalvars
+ implicit none
+
+ real a
+ real c
+ !$acc declare link (c)
+
+ if (acc_is_present (b) .neqv. .false.) call abort
+ if (acc_is_present (c) .neqv. .false.) call abort
+
+ a = 0.0
+ b = 1.0
+
+ !$acc parallel copy (a) copyin (b)
+ b = b + 4.0
+ a = b
+ !$acc end parallel
+
+ if (a .ne. 5.0) call abort
+
+ if (acc_is_present (b) .neqv. .false.) call abort
+
+ a = 0.0
+
+ !$acc parallel copy (a) create (b)
+ b = 4.0
+ a = b
+ !$acc end parallel
+
+ if (a .ne. 4.0) call abort
+
+ if (acc_is_present (b) .neqv. .false.) call abort
+
+ a = 0.0
+
+ !$acc parallel copy (a) copy (b)
+ b = 4.0
+ a = b
+ !$acc end parallel
+
+ if (a .ne. 4.0) call abort
+ if (b .ne. 4.0) call abort
+
+ if (acc_is_present (b) .neqv. .false.) call abort
+
+ a = 0.0
+
+ !$acc parallel copy (a) copy (b) copy (c)
+ b = 4.0
+ c = b
+ a = c
+ !$acc end parallel
+
+ if (a .ne. 4.0) call abort
+
+ if (acc_is_present (b) .neqv. .false.) call abort
+
+end program test
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/declare-4.f90 b/libgomp/testsuite/libgomp.oacc-fortran/declare-4.f90
new file mode 100644
index 0000000..226264e
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-fortran/declare-4.f90
@@ -0,0 +1,29 @@
+! { dg-do run { target openacc_nvidia_accel_selected } }
+
+module vars
+ implicit none
+ real b
+ !$acc declare create (b)
+end module vars
+
+program test
+ use vars
+ use openacc
+ implicit none
+ real a
+
+ if (acc_is_present (b) .neqv. .true.) call abort
+
+ a = 2.0
+
+ !$acc parallel copy (a)
+ b = a
+ a = 1.0
+ a = a + b
+ !$acc end parallel
+
+ if (acc_is_present (b) .neqv. .true.) call abort
+
+ if (a .ne. 3.0) call abort
+
+end program test
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/declare-5.f90 b/libgomp/testsuite/libgomp.oacc-fortran/declare-5.f90
new file mode 100644
index 0000000..bcd9c9c
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-fortran/declare-5.f90
@@ -0,0 +1,29 @@
+! { dg-do run { target openacc_nvidia_accel_selected } }
+
+module vars
+ implicit none
+ real b
+ !$acc declare device_resident (b)
+end module vars
+
+program test
+ use vars
+ use openacc
+ implicit none
+ real a
+
+ if (acc_is_present (b) .neqv. .true.) call abort
+
+ a = 2.0
+
+ !$acc parallel copy (a)
+ b = a
+ a = 1.0
+ a = a + b
+ !$acc end parallel
+
+ if (acc_is_present (b) .neqv. .true.) call abort
+
+ if (a .ne. 3.0) call abort
+
+end program test