public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 0/7] [og10] openacc: Arrays/derived types/character type backports
@ 2021-02-24 21:57 Julian Brown
  2021-02-24 21:57 ` [PATCH 1/7] [og10] openacc: Dereference BT_CLASS data pointers but not BT_DERIVED pointers Julian Brown
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Julian Brown @ 2021-02-24 21:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: fortran, Tobias Burnus

This series contains several backports from mainline to the og10 branch
concerning character and complex types and mixed derived types and array
accesses in OpenACC directive clauses.

Tested with offloading to AMD GCN. I will apply shortly.

Julian Brown (5):
  [og10] openacc: Dereference BT_CLASS data pointers but not BT_DERIVED
    pointers
  [og10] openacc: Use class_pointer instead of pointer attribute for
    class types
  [og10] openacc: Character types and mixed arrays/derived type tests
  [og10] openacc: Fix lowering for derived-type mappings through array
    elements
  [og10] openacc: Strided array sections and components of derived-type
    arrays

Tobias Burnus (2):
  [og10] Fortran: OpenMP/OpenACC diagnose substring rejections better
  [og10] Fortran: %re/%im fixes for OpenMP/OpenACC +
    gfc_is_simplify_contiguous

 gcc/ChangeLog.omp                             |   7 +
 gcc/fortran/ChangeLog.omp                     |  43 ++++
 gcc/fortran/expr.c                            |   2 +
 gcc/fortran/openmp.c                          |  66 ++++--
 gcc/fortran/trans-openmp.c                    | 196 ++++++++++--------
 gcc/gimplify.c                                |  12 ++
 gcc/testsuite/ChangeLog.omp                   |  53 +++++
 .../gfortran.dg/goacc/array-with-dt-1.f90     |  11 +
 .../gfortran.dg/goacc/array-with-dt-2.f90     |  10 +
 .../gfortran.dg/goacc/array-with-dt-3.f90     |  14 ++
 .../gfortran.dg/goacc/array-with-dt-4.f90     |  18 ++
 .../gfortran.dg/goacc/array-with-dt-5.f90     |  12 ++
 .../gfortran.dg/goacc/array-with-dt-6.f90     |  10 +
 .../gfortran.dg/goacc/derived-chartypes-1.f90 | 129 ++++++++++++
 .../gfortran.dg/goacc/derived-chartypes-2.f90 | 129 ++++++++++++
 .../gfortran.dg/goacc/derived-chartypes-3.f90 |  38 ++++
 .../gfortran.dg/goacc/derived-chartypes-4.f90 |  38 ++++
 .../goacc/derived-classtypes-1.f95            | 129 ++++++++++++
 .../gfortran.dg/goacc/mapping-tests-2.f90     |   4 +-
 .../gfortran.dg/goacc/ref_inquiry.f90         |  48 +++++
 gcc/testsuite/gfortran.dg/goacc/substring.f90 |  27 +++
 .../gfortran.dg/gomp/ref_inquiry.f90          |  35 ++++
 gcc/testsuite/gfortran.dg/gomp/substring.f90  |  22 ++
 libgomp/ChangeLog.omp                         |  20 ++
 .../array-stride-dt-1.f90                     |  44 ++++
 .../derivedtypes-arrays-1.f90                 | 109 ++++++++++
 .../libgomp.oacc-fortran/update-dt-array.f90  |  53 +++++
 27 files changed, 1176 insertions(+), 103 deletions(-)
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/array-with-dt-1.f90
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/array-with-dt-2.f90
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/array-with-dt-3.f90
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/array-with-dt-4.f90
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/array-with-dt-5.f90
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/array-with-dt-6.f90
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/derived-chartypes-1.f90
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/derived-chartypes-2.f90
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/derived-chartypes-3.f90
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/derived-chartypes-4.f90
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/derived-classtypes-1.f95
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/ref_inquiry.f90
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/substring.f90
 create mode 100644 gcc/testsuite/gfortran.dg/gomp/ref_inquiry.f90
 create mode 100644 gcc/testsuite/gfortran.dg/gomp/substring.f90
 create mode 100644 libgomp/testsuite/libgomp.oacc-fortran/array-stride-dt-1.f90
 create mode 100644 libgomp/testsuite/libgomp.oacc-fortran/derivedtypes-arrays-1.f90
 create mode 100644 libgomp/testsuite/libgomp.oacc-fortran/update-dt-array.f90

-- 
2.29.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/7] [og10] openacc: Dereference BT_CLASS data pointers but not BT_DERIVED pointers
  2021-02-24 21:57 [PATCH 0/7] [og10] openacc: Arrays/derived types/character type backports Julian Brown
@ 2021-02-24 21:57 ` Julian Brown
  2021-02-24 21:57 ` [PATCH 2/7] [og10] openacc: Use class_pointer instead of pointer attribute for class types Julian Brown
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Julian Brown @ 2021-02-24 21:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: fortran, Tobias Burnus

The stanza in gfc_trans_omp_clauses that handles derived type members
that are themselves derived type pointers or class pointers now adds
an explicit dereference only for the latter. The former is already
dereferenced transparently in gfc_conv_component_ref.

gcc/fortran/
	* trans-openmp.c (gfc_trans_omp_clauses): Fix dereferencing for
	BT_DERIVED members.

gcc/testsuite/
	* gfortran.dg/goacc/derived-classtypes-1.f95: New test.

(cherry picked from commit cff6e8db880b6e262730b1ce9a9cb00c1f5571e2)
---
 gcc/fortran/ChangeLog.omp                     |   7 +
 gcc/fortran/trans-openmp.c                    |   7 +-
 gcc/testsuite/ChangeLog.omp                   |   6 +
 .../goacc/derived-classtypes-1.f95            | 129 ++++++++++++++++++
 4 files changed, 146 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/derived-classtypes-1.f95

diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp
index a02606190319..9e0cf7198acf 100644
--- a/gcc/fortran/ChangeLog.omp
+++ b/gcc/fortran/ChangeLog.omp
@@ -1,3 +1,10 @@
+2021-02-24  Julian Brown  <julian@codesourcery.com>
+
+	Backport from mainline
+
+	* trans-openmp.c (gfc_trans_omp_clauses): Fix dereferencing for
+	BT_DERIVED members.
+
 2021-02-12  Tobias Burnus  <tobias@codesourcery.com>
 
 	Backport from mainline
diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c
index 452e2a69baa2..e53f7ebb7d7f 100644
--- a/gcc/fortran/trans-openmp.c
+++ b/gcc/fortran/trans-openmp.c
@@ -2980,6 +2980,8 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
 			  if (lastcomp->u.c.component->ts.type == BT_CLASS)
 			    {
 			      data = gfc_class_data_get (inner);
+			      gcc_assert (POINTER_TYPE_P (TREE_TYPE (data)));
+			      data = build_fold_indirect_ref (data);
 			      size = gfc_class_vtab_size_get (inner);
 			    }
 			  else  /* BT_DERIVED.  */
@@ -2988,8 +2990,7 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
 			      size = TYPE_SIZE_UNIT (TREE_TYPE (inner));
 			    }
 
-			  OMP_CLAUSE_DECL (node)
-			    = build_fold_indirect_ref (data);
+			  OMP_CLAUSE_DECL (node) = data;
 			  OMP_CLAUSE_SIZE (node) = size;
 			  node2 = build_omp_clause (input_location,
 						    OMP_CLAUSE_MAP);
@@ -2997,7 +2998,7 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
 						   openacc
 						   ? GOMP_MAP_ATTACH_DETACH
 						   : GOMP_MAP_ALWAYS_POINTER);
-			  OMP_CLAUSE_DECL (node2) = data;
+			  OMP_CLAUSE_DECL (node2) = build_fold_addr_expr (data);
 			  OMP_CLAUSE_SIZE (node2) = size_int (0);
 			}
 		      else
diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index 8f5512990b85..8caef33f95e4 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -1,3 +1,9 @@
+2021-02-24  Julian Brown  <julian@codesourcery.com>
+
+	Backport from mainline
+
+	* gfortran.dg/goacc/derived-classtypes-1.f95: New test.
+
 2021-02-12  Tobias Burnus  <tobias@codesourcery.com>
 
 	Backport from mainline
diff --git a/gcc/testsuite/gfortran.dg/goacc/derived-classtypes-1.f95 b/gcc/testsuite/gfortran.dg/goacc/derived-classtypes-1.f95
new file mode 100644
index 000000000000..e6cf09c6d3c1
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc/derived-classtypes-1.f95
@@ -0,0 +1,129 @@
+type :: type1
+  integer :: a
+end type type1
+
+type :: type2
+  integer, pointer :: b
+end type type2
+
+type :: aux1
+  integer :: y
+end type aux1
+
+type, extends(aux1) :: aux
+  integer :: x
+end type aux
+
+type :: type3
+  class(aux), pointer :: c(:)
+end type type3
+
+type :: type4
+  integer, pointer :: d(:)
+end type type4
+
+type :: type5
+  type(aux) :: e
+end type type5
+
+type :: type6
+  type(aux), pointer :: f
+end type type6
+
+type :: type7
+  class(aux), pointer :: g
+end type type7
+
+type(type1) :: foo
+type(type2) :: bar
+type(type3) :: qux
+type(type4) :: quux
+type(type5) :: fred
+type(type6) :: jim
+type(type7) :: shiela
+
+type(type1), pointer :: pfoo
+type(type2), pointer :: pbar
+type(type3), pointer :: pqux
+type(type4), pointer :: pquux
+type(type5), pointer :: pfred
+type(type6), pointer :: pjim
+type(type7), pointer :: pshiela
+
+class(type1), pointer :: cfoo
+class(type2), pointer :: cbar
+class(type3), pointer :: cqux
+class(type4), pointer :: cquux
+class(type5), pointer :: cfred
+class(type6), pointer :: cjim
+class(type7), pointer :: cshiela
+
+class(type1), allocatable :: acfoo
+class(type2), allocatable :: acbar
+class(type3), allocatable :: acqux
+class(type4), allocatable :: acquux
+class(type5), allocatable :: acfred
+class(type6), allocatable :: acjim
+class(type7), allocatable :: acshiela
+
+!$acc enter data copyin(foo)
+!$acc enter data copyin(foo%a)
+!$acc enter data copyin(bar)
+!$acc enter data copyin(bar%b)
+!$acc enter data copyin(qux)
+!!$acc enter data copyin(qux%c)
+!$acc enter data copyin(quux)
+!$acc enter data copyin(quux%d)
+!$acc enter data copyin(fred)
+!$acc enter data copyin(fred%e)
+!$acc enter data copyin(jim)
+!$acc enter data copyin(jim%f)
+!$acc enter data copyin(shiela)
+!$acc enter data copyin(shiela%g)
+
+!$acc enter data copyin(pfoo)
+!$acc enter data copyin(pfoo%a)
+!$acc enter data copyin(pbar)
+!$acc enter data copyin(pbar%b)
+!$acc enter data copyin(pqux)
+!!$acc enter data copyin(pqux%c)
+!$acc enter data copyin(pquux)
+!$acc enter data copyin(pquux%d)
+!$acc enter data copyin(pfred)
+!$acc enter data copyin(pfred%e)
+!$acc enter data copyin(pjim)
+!$acc enter data copyin(pjim%f)
+!$acc enter data copyin(pshiela)
+!$acc enter data copyin(pshiela%g)
+
+!$acc enter data copyin(cfoo)
+!$acc enter data copyin(cfoo%a)
+!$acc enter data copyin(cbar)
+!$acc enter data copyin(cbar%b)
+!$acc enter data copyin(cqux)
+!!$acc enter data copyin(cqux%c)
+!$acc enter data copyin(cquux)
+!$acc enter data copyin(cquux%d)
+!$acc enter data copyin(cfred)
+!$acc enter data copyin(cfred%e)
+!$acc enter data copyin(cjim)
+!$acc enter data copyin(cjim%f)
+!$acc enter data copyin(cshiela)
+!$acc enter data copyin(cshiela%g)
+
+!$acc enter data copyin(acfoo)
+!$acc enter data copyin(acfoo%a)
+!$acc enter data copyin(acbar)
+!$acc enter data copyin(acbar%b)
+!$acc enter data copyin(acqux)
+!!$acc enter data copyin(acqux%c)
+!$acc enter data copyin(acquux)
+!$acc enter data copyin(acquux%d)
+!$acc enter data copyin(acfred)
+!$acc enter data copyin(acfred%e)
+!$acc enter data copyin(acjim)
+!$acc enter data copyin(acjim%f)
+!$acc enter data copyin(acshiela)
+!$acc enter data copyin(acshiela%g)
+
+end
-- 
2.29.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/7] [og10] openacc: Use class_pointer instead of pointer attribute for class types
  2021-02-24 21:57 [PATCH 0/7] [og10] openacc: Arrays/derived types/character type backports Julian Brown
  2021-02-24 21:57 ` [PATCH 1/7] [og10] openacc: Dereference BT_CLASS data pointers but not BT_DERIVED pointers Julian Brown
@ 2021-02-24 21:57 ` Julian Brown
  2021-02-24 21:57 ` [PATCH 3/7] [og10] openacc: Character types and mixed arrays/derived type tests Julian Brown
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Julian Brown @ 2021-02-24 21:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: fortran, Tobias Burnus

Elsewhere in the Fortran front-end, the class_pointer attribute is
used for BT_CLASS entities instead of the pointer attribute. This patch
follows suit for OpenACC. I couldn't actually come up with a test case
where this makes a difference (i.e., where "class_pointer" and "pointer"
have different values at this point in the code), but this may nonetheless
fix a latent bug.

gcc/fortran/
	* trans-openmp.c (gfc_trans_omp_clauses): Use class_pointer attribute
	for BT_CLASS.

(cherry picked from commit f743fe231663e32d52db987650d0ec3381a777af)
---
 gcc/fortran/ChangeLog.omp  | 7 +++++++
 gcc/fortran/trans-openmp.c | 5 ++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp
index 9e0cf7198acf..2dd82a70cb71 100644
--- a/gcc/fortran/ChangeLog.omp
+++ b/gcc/fortran/ChangeLog.omp
@@ -1,3 +1,10 @@
+2021-02-24  Julian Brown  <julian@codesourcery.com>
+
+	Backport from mainline
+
+	* trans-openmp.c (gfc_trans_omp_clauses): Use class_pointer attribute
+	for BT_CLASS.
+
 2021-02-24  Julian Brown  <julian@codesourcery.com>
 
 	Backport from mainline
diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c
index e53f7ebb7d7f..d0e299b02142 100644
--- a/gcc/fortran/trans-openmp.c
+++ b/gcc/fortran/trans-openmp.c
@@ -2973,7 +2973,10 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
 		  if (lastcomp->u.c.component->ts.type == BT_DERIVED
 		      || lastcomp->u.c.component->ts.type == BT_CLASS)
 		    {
-		      if (sym_attr.pointer || (openacc && sym_attr.allocatable))
+		      bool pointer
+			= (lastcomp->u.c.component->ts.type == BT_CLASS
+			   ? sym_attr.class_pointer : sym_attr.pointer);
+		      if (pointer || (openacc && sym_attr.allocatable))
 			{
 			  tree data, size;
 
-- 
2.29.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 3/7] [og10] openacc: Character types and mixed arrays/derived type tests
  2021-02-24 21:57 [PATCH 0/7] [og10] openacc: Arrays/derived types/character type backports Julian Brown
  2021-02-24 21:57 ` [PATCH 1/7] [og10] openacc: Dereference BT_CLASS data pointers but not BT_DERIVED pointers Julian Brown
  2021-02-24 21:57 ` [PATCH 2/7] [og10] openacc: Use class_pointer instead of pointer attribute for class types Julian Brown
@ 2021-02-24 21:57 ` Julian Brown
  2021-02-24 21:57 ` [PATCH 4/7] [og10] Fortran: OpenMP/OpenACC diagnose substring rejections better Julian Brown
  2021-02-25 15:30 ` [OG10] backport an additional commit – was: [PATCH 0/7] [og10] openacc: Arrays/derived types/character type backports Tobias Burnus
  4 siblings, 0 replies; 6+ messages in thread
From: Julian Brown @ 2021-02-24 21:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: fortran, Tobias Burnus

This patch adds some tests for character types that are components
of derived types used in OpenACC data-movement clauses (some of which
currently fail and are thus XFAILed), and tests (also XFAILed) mixing
arrays and derived types.  The XFAILs are addressed by follow-on patches.
Originally a combination of several mainline patches.

(cherry picked from commit b2d84e9f9cccbe4ee662f7002b83105629d09939)
(cherry picked from commit 9a4d32f85ccebc0ee4b24e6d9d7a4f11c04d7146)
(cherry picked from commit b0fb2720d88d680af18981a2097397196b505a1f)
(cherry picked from commit f7fb2f662fe12f327ece8b034ab76b36fdca4696)

gcc/testsuite/
	* gfortran.dg/goacc/array-with-dt-2.f90: New test.
	* gfortran.dg/goacc/derived-chartypes-1.f90: Likewise.
	* gfortran.dg/goacc/derived-chartypes-2.f90: Likewise.
	* gfortran.dg/goacc/derived-chartypes-3.f90: Likewise.
	* gfortran.dg/goacc/derived-chartypes-4.f90: Likewise.

libgomp/
	* testsuite/libgomp.oacc-fortran/array-stride-dt-1.f90: New test.
---
 gcc/testsuite/ChangeLog.omp                   |  10 ++
 .../gfortran.dg/goacc/array-with-dt-2.f90     |  11 ++
 .../gfortran.dg/goacc/derived-chartypes-1.f90 | 132 ++++++++++++++++++
 .../gfortran.dg/goacc/derived-chartypes-2.f90 | 132 ++++++++++++++++++
 .../gfortran.dg/goacc/derived-chartypes-3.f90 |  38 +++++
 .../gfortran.dg/goacc/derived-chartypes-4.f90 |  38 +++++
 libgomp/ChangeLog.omp                         |   6 +
 .../array-stride-dt-1.f90                     |  45 ++++++
 8 files changed, 412 insertions(+)
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/array-with-dt-2.f90
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/derived-chartypes-1.f90
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/derived-chartypes-2.f90
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/derived-chartypes-3.f90
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/derived-chartypes-4.f90
 create mode 100644 libgomp/testsuite/libgomp.oacc-fortran/array-stride-dt-1.f90

diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index 8caef33f95e4..e04a4ee3ebff 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -1,3 +1,13 @@
+2021-02-24  Julian Brown  <julian@codesourcery.com>
+
+	Backport from mainline
+
+	* gfortran.dg/goacc/array-with-dt-2.f90: New test.
+	* gfortran.dg/goacc/derived-chartypes-1.f90: Likewise.
+	* gfortran.dg/goacc/derived-chartypes-2.f90: Likewise.
+	* gfortran.dg/goacc/derived-chartypes-3.f90: Likewise.
+	* gfortran.dg/goacc/derived-chartypes-4.f90: Likewise.
+
 2021-02-24  Julian Brown  <julian@codesourcery.com>
 
 	Backport from mainline
diff --git a/gcc/testsuite/gfortran.dg/goacc/array-with-dt-2.f90 b/gcc/testsuite/gfortran.dg/goacc/array-with-dt-2.f90
new file mode 100644
index 000000000000..e4a6f319772c
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc/array-with-dt-2.f90
@@ -0,0 +1,11 @@
+type t
+   integer, allocatable :: A(:,:)
+end type t
+
+type(t), allocatable :: b(:)
+
+! TODO: Remove expected errors when this is supported.
+!$acc update host(b(::2))  ! { dg-error "Stride should not be specified for array section in MAP clause" }
+!$acc update host(b(1)%A(::3,::4))  ! { dg-error "Stride should not be specified for array section in MAP clause" }
+end
+
diff --git a/gcc/testsuite/gfortran.dg/goacc/derived-chartypes-1.f90 b/gcc/testsuite/gfortran.dg/goacc/derived-chartypes-1.f90
new file mode 100644
index 000000000000..f7aafbfc036f
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc/derived-chartypes-1.f90
@@ -0,0 +1,132 @@
+! This currently ICEs. Avoid that.
+! { dg-skip-if "PR98979" { *-*-* } }
+
+type :: type1
+  character(len=35) :: a
+end type type1
+
+type :: type2
+  character(len=35), pointer :: b
+end type type2
+
+type :: aux1
+  character(len=22) :: y
+end type aux1
+
+type, extends(aux1) :: aux
+  character(len=33) :: x
+end type aux
+
+type :: type3
+  class(aux), pointer :: c(:)
+end type type3
+
+type :: type4
+  integer, pointer :: d(:)
+end type type4
+
+type :: type5
+  type(aux1) :: e
+end type type5
+
+type :: type6
+  type(aux1), pointer :: f
+end type type6
+
+type :: type7
+  class(aux), pointer :: g
+end type type7
+
+type(type1) :: foo
+type(type2) :: bar
+type(type3) :: qux
+type(type4) :: quux
+type(type5) :: fred
+type(type6) :: jim
+type(type7) :: shiela
+
+type(type1), pointer :: pfoo
+type(type2), pointer :: pbar
+type(type3), pointer :: pqux
+type(type4), pointer :: pquux
+type(type5), pointer :: pfred
+type(type6), pointer :: pjim
+type(type7), pointer :: pshiela
+
+class(type1), pointer :: cfoo
+class(type2), pointer :: cbar
+class(type3), pointer :: cqux
+class(type4), pointer :: cquux
+class(type5), pointer :: cfred
+class(type6), pointer :: cjim
+class(type7), pointer :: cshiela
+
+class(type1), allocatable :: acfoo
+class(type2), allocatable :: acbar
+class(type3), allocatable :: acqux
+class(type4), allocatable :: acquux
+class(type5), allocatable :: acfred
+class(type6), allocatable :: acjim
+class(type7), allocatable :: acshiela
+
+!$acc enter data copyin(foo)
+!$acc enter data copyin(foo%a)
+!$acc enter data copyin(bar)
+!$acc enter data copyin(bar%b)
+!$acc enter data copyin(qux)
+!$acc enter data copyin(qux%c)
+!$acc enter data copyin(quux)
+!$acc enter data copyin(quux%d)
+!$acc enter data copyin(fred)
+!$acc enter data copyin(fred%e)
+!$acc enter data copyin(jim)
+!$acc enter data copyin(jim%f)
+!$acc enter data copyin(shiela)
+!$acc enter data copyin(shiela%g)
+
+!$acc enter data copyin(pfoo)
+!$acc enter data copyin(pfoo%a)
+!$acc enter data copyin(pbar)
+!$acc enter data copyin(pbar%b)
+!$acc enter data copyin(pqux)
+!$acc enter data copyin(pqux%c)
+!$acc enter data copyin(pquux)
+!$acc enter data copyin(pquux%d)
+!$acc enter data copyin(pfred)
+!$acc enter data copyin(pfred%e)
+!$acc enter data copyin(pjim)
+!$acc enter data copyin(pjim%f)
+!$acc enter data copyin(pshiela)
+!$acc enter data copyin(pshiela%g)
+
+!$acc enter data copyin(cfoo)
+!$acc enter data copyin(cfoo%a)
+!$acc enter data copyin(cbar)
+!$acc enter data copyin(cbar%b)
+!$acc enter data copyin(cqux)
+!$acc enter data copyin(cqux%c)
+!$acc enter data copyin(cquux)
+!$acc enter data copyin(cquux%d)
+!$acc enter data copyin(cfred)
+!$acc enter data copyin(cfred%e)
+!$acc enter data copyin(cjim)
+!$acc enter data copyin(cjim%f)
+!$acc enter data copyin(cshiela)
+!$acc enter data copyin(cshiela%g)
+
+!$acc enter data copyin(acfoo)
+!$acc enter data copyin(acfoo%a)
+!$acc enter data copyin(acbar)
+!$acc enter data copyin(acbar%b)
+!$acc enter data copyin(acqux)
+!$acc enter data copyin(acqux%c)
+!$acc enter data copyin(acquux)
+!$acc enter data copyin(acquux%d)
+!$acc enter data copyin(acfred)
+!$acc enter data copyin(acfred%e)
+!$acc enter data copyin(acjim)
+!$acc enter data copyin(acjim%f)
+!$acc enter data copyin(acshiela)
+!$acc enter data copyin(acshiela%g)
+
+end
diff --git a/gcc/testsuite/gfortran.dg/goacc/derived-chartypes-2.f90 b/gcc/testsuite/gfortran.dg/goacc/derived-chartypes-2.f90
new file mode 100644
index 000000000000..e22fc679df2b
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc/derived-chartypes-2.f90
@@ -0,0 +1,132 @@
+! This currently ICEs. Avoid that.
+! { dg-skip-if "PR98979" { *-*-* } }
+
+type :: type1
+  character(len=35,kind=4) :: a
+end type type1
+
+type :: type2
+  character(len=35,kind=4), pointer :: b
+end type type2
+
+type :: aux1
+  character(len=22,kind=4) :: y
+end type aux1
+
+type, extends(aux1) :: aux
+  character(len=33,kind=4) :: x
+end type aux
+
+type :: type3
+  class(aux), pointer :: c(:)
+end type type3
+
+type :: type4
+  integer, pointer :: d(:)
+end type type4
+
+type :: type5
+  type(aux1) :: e
+end type type5
+
+type :: type6
+  type(aux1), pointer :: f
+end type type6
+
+type :: type7
+  class(aux), pointer :: g
+end type type7
+
+type(type1) :: foo
+type(type2) :: bar
+type(type3) :: qux
+type(type4) :: quux
+type(type5) :: fred
+type(type6) :: jim
+type(type7) :: shiela
+
+type(type1), pointer :: pfoo
+type(type2), pointer :: pbar
+type(type3), pointer :: pqux
+type(type4), pointer :: pquux
+type(type5), pointer :: pfred
+type(type6), pointer :: pjim
+type(type7), pointer :: pshiela
+
+class(type1), pointer :: cfoo
+class(type2), pointer :: cbar
+class(type3), pointer :: cqux
+class(type4), pointer :: cquux
+class(type5), pointer :: cfred
+class(type6), pointer :: cjim
+class(type7), pointer :: cshiela
+
+class(type1), allocatable :: acfoo
+class(type2), allocatable :: acbar
+class(type3), allocatable :: acqux
+class(type4), allocatable :: acquux
+class(type5), allocatable :: acfred
+class(type6), allocatable :: acjim
+class(type7), allocatable :: acshiela
+
+!$acc enter data copyin(foo)
+!$acc enter data copyin(foo%a)
+!$acc enter data copyin(bar)
+!$acc enter data copyin(bar%b)
+!$acc enter data copyin(qux)
+!$acc enter data copyin(qux%c)
+!$acc enter data copyin(quux)
+!$acc enter data copyin(quux%d)
+!$acc enter data copyin(fred)
+!$acc enter data copyin(fred%e)
+!$acc enter data copyin(jim)
+!$acc enter data copyin(jim%f)
+!$acc enter data copyin(shiela)
+!$acc enter data copyin(shiela%g)
+
+!$acc enter data copyin(pfoo)
+!$acc enter data copyin(pfoo%a)
+!$acc enter data copyin(pbar)
+!$acc enter data copyin(pbar%b)
+!$acc enter data copyin(pqux)
+!$acc enter data copyin(pqux%c)
+!$acc enter data copyin(pquux)
+!$acc enter data copyin(pquux%d)
+!$acc enter data copyin(pfred)
+!$acc enter data copyin(pfred%e)
+!$acc enter data copyin(pjim)
+!$acc enter data copyin(pjim%f)
+!$acc enter data copyin(pshiela)
+!$acc enter data copyin(pshiela%g)
+
+!$acc enter data copyin(cfoo)
+!$acc enter data copyin(cfoo%a)
+!$acc enter data copyin(cbar)
+!$acc enter data copyin(cbar%b)
+!$acc enter data copyin(cqux)
+!$acc enter data copyin(cqux%c)
+!$acc enter data copyin(cquux)
+!$acc enter data copyin(cquux%d)
+!$acc enter data copyin(cfred)
+!$acc enter data copyin(cfred%e)
+!$acc enter data copyin(cjim)
+!$acc enter data copyin(cjim%f)
+!$acc enter data copyin(cshiela)
+!$acc enter data copyin(cshiela%g)
+
+!$acc enter data copyin(acfoo)
+!$acc enter data copyin(acfoo%a)
+!$acc enter data copyin(acbar)
+!$acc enter data copyin(acbar%b)
+!$acc enter data copyin(acqux)
+!$acc enter data copyin(acqux%c)
+!$acc enter data copyin(acquux)
+!$acc enter data copyin(acquux%d)
+!$acc enter data copyin(acfred)
+!$acc enter data copyin(acfred%e)
+!$acc enter data copyin(acjim)
+!$acc enter data copyin(acjim%f)
+!$acc enter data copyin(acshiela)
+!$acc enter data copyin(acshiela%g)
+
+end
diff --git a/gcc/testsuite/gfortran.dg/goacc/derived-chartypes-3.f90 b/gcc/testsuite/gfortran.dg/goacc/derived-chartypes-3.f90
new file mode 100644
index 000000000000..2bab497cef5d
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc/derived-chartypes-3.f90
@@ -0,0 +1,38 @@
+! { dg-additional-options "-fdump-tree-gimple" }
+
+type :: type1
+  character(len=35) :: a
+end type type1
+
+type :: type2
+  character(len=46), pointer :: b
+end type type2
+
+type(type1) :: foo
+type(type2) :: bar
+
+type(type1), pointer :: pfoo
+type(type2), pointer :: pbar
+
+class(type1), pointer :: cfoo
+class(type2), pointer :: cbar
+
+class(type1), allocatable :: acfoo
+class(type2), allocatable :: acbar
+
+!$acc enter data copyin(foo%a)
+!$acc enter data copyin(bar%b)
+
+!$acc enter data copyin(pfoo%a)
+!$acc enter data copyin(pbar%b)
+
+!$acc enter data copyin(cfoo%a)
+!$acc enter data copyin(cbar%b)
+
+!$acc enter data copyin(acfoo%a)
+!$acc enter data copyin(acbar%b)
+
+! { dg-final { scan-tree-dump-times "to:\[^\\\[\]*\\\[len: 35\\\]" 4 "gimple" } }
+! { dg-final { scan-tree-dump-times "to:\[^\\\[\]*\\\[len: 46\\\]" 4 "gimple" } }
+
+end
diff --git a/gcc/testsuite/gfortran.dg/goacc/derived-chartypes-4.f90 b/gcc/testsuite/gfortran.dg/goacc/derived-chartypes-4.f90
new file mode 100644
index 000000000000..cfe40066a595
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc/derived-chartypes-4.f90
@@ -0,0 +1,38 @@
+! { dg-additional-options "-fdump-tree-gimple" }
+
+type :: type1
+  character(len=35,kind=4) :: a
+end type type1
+
+type :: type2
+  character(len=46,kind=4), pointer :: b
+end type type2
+
+type(type1) :: foo
+type(type2) :: bar
+
+type(type1), pointer :: pfoo
+type(type2), pointer :: pbar
+
+class(type1), pointer :: cfoo
+class(type2), pointer :: cbar
+
+class(type1), allocatable :: acfoo
+class(type2), allocatable :: acbar
+
+!$acc enter data copyin(foo%a)
+!$acc enter data copyin(bar%b)
+
+!$acc enter data copyin(pfoo%a)
+!$acc enter data copyin(pbar%b)
+
+!$acc enter data copyin(cfoo%a)
+!$acc enter data copyin(cbar%b)
+
+!$acc enter data copyin(acfoo%a)
+!$acc enter data copyin(acbar%b)
+
+! { dg-final { scan-tree-dump-times "to:\[^\\\[\]*\\\[len: 140\\\]" 4 "gimple" } }
+! { dg-final { scan-tree-dump-times "to:\[^\\\[\]*\\\[len: 184\\\]" 4 "gimple" } }
+
+end
diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index addab7d05c5f..db6ac79fe123 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -1,3 +1,9 @@
+2021-02-24  Julian Brown  <julian@codesourcery.com>
+
+	Backport from mainline
+
+	* testsuite/libgomp.oacc-fortran/array-stride-dt-1.f90: New test.
+
 2021-02-09  Kwok Cheung Yeung  <kcy@codesourcery.com>
 
 	Backport from mainline
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/array-stride-dt-1.f90 b/libgomp/testsuite/libgomp.oacc-fortran/array-stride-dt-1.f90
new file mode 100644
index 000000000000..61250708197d
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-fortran/array-stride-dt-1.f90
@@ -0,0 +1,45 @@
+! { dg-do run }
+
+type t
+   integer, allocatable :: A(:,:)
+end type t
+
+type(t), allocatable :: b(:)
+
+integer :: i
+
+allocate(b(1:20))
+do i=1,20
+  allocate(b(i)%A(1:20,1:20))
+end do
+
+do i=1,20
+  b(i)%A(:,:) = 0
+end do
+
+!$acc enter data copyin(b)
+do i=1,20
+  !$acc enter data copyin(b(i)%A)
+end do
+
+b(1)%A(:,:) = 5
+
+! TODO: Remove expected errors once this is supported.
+!$acc update device(b(::2))  ! { dg-error "Stride should not be specified for array section in MAP clause" }
+!$acc update device(b(1)%A(::3,::4))  ! { dg-error "Stride should not be specified for array section in MAP clause" }
+
+do i=1,20
+  !$acc exit data copyout(b(i)%A)
+end do
+!$acc exit data copyout(b)
+
+! This is necessarily conservative because the "update" is allowed to copy
+! e.g. the whole of the containing block for a discontinuous update.
+! Try to ensure that the update covers a sufficient portion of the array.
+
+if (any(b(1)%A(::3,::4) .ne. 5)) stop 1
+do i=2,20
+  if (any(b(i)%A(:,:) .ne. 0)) stop 2
+end do
+
+end
-- 
2.29.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 4/7] [og10] Fortran: OpenMP/OpenACC diagnose substring rejections better
  2021-02-24 21:57 [PATCH 0/7] [og10] openacc: Arrays/derived types/character type backports Julian Brown
                   ` (2 preceding siblings ...)
  2021-02-24 21:57 ` [PATCH 3/7] [og10] openacc: Character types and mixed arrays/derived type tests Julian Brown
@ 2021-02-24 21:57 ` Julian Brown
  2021-02-25 15:30 ` [OG10] backport an additional commit – was: [PATCH 0/7] [og10] openacc: Arrays/derived types/character type backports Tobias Burnus
  4 siblings, 0 replies; 6+ messages in thread
From: Julian Brown @ 2021-02-24 21:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: fortran, Tobias Burnus

From: Tobias Burnus <tobias@codesourcery.com>

gcc/fortran/ChangeLog:

	* openmp.c (resolve_omp_clauses): Explicitly diagnose
	substrings as not permitted.

gcc/testsuite/ChangeLog:

	* gfortran.dg/goacc/substring.f90: New test.
	* gfortran.dg/gomp/substring.f90: New test.

(cherry picked from commit f0e618faeb619ec02dabbef203a5575fca44a7f7)
---
 gcc/fortran/ChangeLog.omp                     |  7 +++++
 gcc/fortran/openmp.c                          |  8 +++++-
 gcc/testsuite/ChangeLog.omp                   |  7 +++++
 gcc/testsuite/gfortran.dg/goacc/substring.f90 | 27 +++++++++++++++++++
 gcc/testsuite/gfortran.dg/gomp/substring.f90  | 22 +++++++++++++++
 5 files changed, 70 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gfortran.dg/goacc/substring.f90
 create mode 100644 gcc/testsuite/gfortran.dg/gomp/substring.f90

diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp
index 2dd82a70cb71..09c2bb855c88 100644
--- a/gcc/fortran/ChangeLog.omp
+++ b/gcc/fortran/ChangeLog.omp
@@ -1,3 +1,10 @@
+2021-02-24  Tobias Burnus  <tobias@codesourcery.com>
+
+	Backport from mainline
+
+	* openmp.c (resolve_omp_clauses): Explicitly diagnose
+	substrings as not permitted.
+
 2021-02-24  Julian Brown  <julian@codesourcery.com>
 
 	Backport from mainline
diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c
index 61a340d7f396..a7592f0545d9 100644
--- a/gcc/fortran/openmp.c
+++ b/gcc/fortran/openmp.c
@@ -4978,7 +4978,13 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses,
 		    || (n->expr
 			&& (!resolved || n->expr->expr_type != EXPR_VARIABLE)))
 		  {
-		    if (!resolved
+		    if (array_ref
+			&& (array_ref->type == REF_SUBSTRING
+			    || (array_ref->next
+				&& array_ref->next->type == REF_SUBSTRING)))
+		      gfc_error ("Unexpected substring reference in %s clause "
+				 "at %L", name, &n->where);
+		    else if (!resolved
 			|| n->expr->expr_type != EXPR_VARIABLE
 			|| array_ref->next
 			|| array_ref->type != REF_ARRAY)
diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index e04a4ee3ebff..d012e9e75b4e 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -1,3 +1,10 @@
+2021-02-24  Tobias Burnus  <tobias@codesourcery.com>
+
+	Backport from mainline
+
+	* gfortran.dg/goacc/substring.f90: New test.
+	* gfortran.dg/gomp/substring.f90: New test.
+
 2021-02-24  Julian Brown  <julian@codesourcery.com>
 
 	Backport from mainline
diff --git a/gcc/testsuite/gfortran.dg/goacc/substring.f90 b/gcc/testsuite/gfortran.dg/goacc/substring.f90
new file mode 100644
index 000000000000..25031daddf33
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc/substring.f90
@@ -0,0 +1,27 @@
+implicit none
+character(len=10) :: str1, str2(5,5)
+
+type t
+  character(len=10) :: str1, str2(5,5)
+end type t
+type(t) :: v
+
+!$acc enter data copyin(v%str1)       ! OK
+!$acc enter data copyin(v%str2)       ! OK
+!$acc enter data copyin(v%str2(1,2))  ! OK
+!$acc enter data copyin(str1)         ! OK
+!$acc enter data copyin(str2)         ! OK
+!$acc enter data copyin(str2(1,2))    ! OK
+
+!$acc enter data copyin(v%str1(2:5))       ! { dg-error "Unexpected substring reference in MAP clause" }
+!$acc enter data copyin(v%str2(1,2)(2:4))  ! { dg-error "Unexpected substring reference in MAP clause" }
+!$acc enter data copyin(str1(2:5))         ! { dg-error "Unexpected substring reference in MAP clause" }
+!$acc enter data copyin(str2(1,2)(2:4))    ! { dg-error "Unexpected substring reference in MAP clause" }
+
+!$acc parallel
+!$acc update host(v%str1(2:5))             ! { dg-error "Unexpected substring reference in MAP clause" }
+!$acc update host(v%str2(1,2)(2:4))        ! { dg-error "Unexpected substring reference in MAP clause" }
+!$acc update host(str1(2:5))               ! { dg-error "Unexpected substring reference in MAP clause" }
+!$acc update host(str2(1,2)(2:4))          ! { dg-error "Unexpected substring reference in MAP clause" }
+!$acc end parallel
+end
diff --git a/gcc/testsuite/gfortran.dg/gomp/substring.f90 b/gcc/testsuite/gfortran.dg/gomp/substring.f90
new file mode 100644
index 000000000000..23d7fb7e48ab
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/substring.f90
@@ -0,0 +1,22 @@
+implicit none
+character(len=10) :: str1, str2(5,5)
+
+type t
+  character(len=10) :: str1, str2(5,5)
+end type t
+type(t) :: v
+
+!$omp target enter data map(to: str1)      ! OK
+!$omp target enter data map(to: str2)      ! OK
+!$omp target enter data map(to: str2(2,5)) ! OK
+
+!$omp target enter data map(to: str1(2,5))         ! { dg-error "Syntax error in OpenMP variable list" }
+!$omp target enter data map(to: str2(1,2)(2:4))    ! { dg-error "Unexpected substring reference in MAP clause" }
+
+!$omp target enter data map(to: v%str1)       ! OK
+!$omp target enter data map(to: v%str2)       ! OK
+!$omp target enter data map(to: v%str2(1,2))  ! OK
+
+!$omp target enter data map(to: v%str1(2:5))       ! { dg-error "Unexpected substring reference in MAP clause" }
+!$omp target enter data map(to: v%str2(1,2)(2:4))  ! { dg-error "Unexpected substring reference in MAP clause" }
+end
-- 
2.29.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [OG10] backport an additional commit – was: [PATCH 0/7] [og10] openacc: Arrays/derived types/character type backports
  2021-02-24 21:57 [PATCH 0/7] [og10] openacc: Arrays/derived types/character type backports Julian Brown
                   ` (3 preceding siblings ...)
  2021-02-24 21:57 ` [PATCH 4/7] [og10] Fortran: OpenMP/OpenACC diagnose substring rejections better Julian Brown
@ 2021-02-25 15:30 ` Tobias Burnus
  4 siblings, 0 replies; 6+ messages in thread
From: Tobias Burnus @ 2021-02-25 15:30 UTC (permalink / raw)
  To: Julian Brown, gcc-patches; +Cc: fortran

On 24.02.21 22:57, Julian Brown wrote:

> This series contains several backports from mainline to the og10 branch

I have now also backported mainline commit
https://gcc.gnu.org/g:65167982efa4dbb96698d026e6d7e17acb513f0a
Fortran: add contiguous check for ptr assignment, fix non-contig check
(PR97242)

which relates to the contiguous check - which did not handle
derived-type components, popping up with some derived-type access in
clauses.

Tobias

-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank Thürauf

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-02-25 15:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-24 21:57 [PATCH 0/7] [og10] openacc: Arrays/derived types/character type backports Julian Brown
2021-02-24 21:57 ` [PATCH 1/7] [og10] openacc: Dereference BT_CLASS data pointers but not BT_DERIVED pointers Julian Brown
2021-02-24 21:57 ` [PATCH 2/7] [og10] openacc: Use class_pointer instead of pointer attribute for class types Julian Brown
2021-02-24 21:57 ` [PATCH 3/7] [og10] openacc: Character types and mixed arrays/derived type tests Julian Brown
2021-02-24 21:57 ` [PATCH 4/7] [og10] Fortran: OpenMP/OpenACC diagnose substring rejections better Julian Brown
2021-02-25 15:30 ` [OG10] backport an additional commit – was: [PATCH 0/7] [og10] openacc: Arrays/derived types/character type backports Tobias Burnus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).