[gcc/devel/omp/gcc-16] OpenMP/Fortran: 'target update' with strides + DT components

Sandra Loosemore via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:bc0a38125ca25db78ad60e29de11dc9f87a12baa

commit bc0a38125ca25db78ad60e29de11dc9f87a12baa
Author: Tobias Burnus <[email protected]>
Date:   Wed Nov 2 09:06:28 2022 +0100

    OpenMP/Fortran: 'target update' with strides + DT components
    
    OpenMP 5.0 permits to use arrays with strides and derived
    type components for the list items to the 'from'/'to' clauses
    of the 'target update' directive.
    
    Partially committed to mainline as:
    
    6629444170f85  OpenMP/Fortran: 'target update' with DT components
    
    This patch contains the differences to the mainline version.
    
    gcc/fortran/ChangeLog:
    
            * openmp.cc (resolve_omp_clauses_aff_dep_map_cache): Apply
            to OpenMP target update.
    
    libgomp/ChangeLog:
    
            * testsuite/libgomp.fortran/target-13.f90: Update test.

Diff:
---
 gcc/fortran/openmp.cc                           |  9 +++++++--
 libgomp/testsuite/libgomp.fortran/target-13.f90 | 13 ++++++++-----
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc
index 62f3f44a9f7f..ea4b85a7ff6c 100644
--- a/gcc/fortran/openmp.cc
+++ b/gcc/fortran/openmp.cc
@@ -9985,8 +9985,11 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses,
 			   Only raise an error here if we're really sure the
 			   array isn't contiguous.  An expression such as
 			   arr(-n:n,-n:n) could be contiguous even if it looks
-			   like it may not be.  */
+			   like it may not be.
+			   And OpenMP's 'target update' permits strides for
+			   the to/from clause. */
 			if (code->op != EXEC_OACC_UPDATE
+			    && code->op != EXEC_OMP_TARGET_UPDATE
 			    && list != OMP_LIST_CACHE
 			    && list != OMP_LIST_DEPEND
 			    && !gfc_is_simply_contiguous (n->expr, false, true)
@@ -10052,7 +10055,9 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses,
 			int i;
 			gfc_array_ref *ar = &lastslice->u.ar;
 			for (i = 0; i < ar->dimen; i++)
-			  if (ar->stride[i] && code->op != EXEC_OACC_UPDATE)
+			  if (ar->stride[i]
+			      && code->op != EXEC_OACC_UPDATE
+			      && code->op != EXEC_OMP_TARGET_UPDATE)
 			    {
 			      gfc_error ("Stride should not be specified for "
 					 "array section in %s clause at %L",
diff --git a/libgomp/testsuite/libgomp.fortran/target-13.f90 b/libgomp/testsuite/libgomp.fortran/target-13.f90
index 6aacc7784494..e6334a5275f9 100644
--- a/libgomp/testsuite/libgomp.fortran/target-13.f90
+++ b/libgomp/testsuite/libgomp.fortran/target-13.f90
@@ -76,7 +76,7 @@ var3a = var3
 
 ! ---------------
 
-!$omp target update from(var1%at(2:3))
+!$omp target update from(var1%at(::2))
 
 if (var1a /= var1) error stop
 if (any (var2a /= var2)) error stop
@@ -134,17 +134,20 @@ var1a%at(2)%a = var1a%at(2)%a * 7
 var1a%at(3)%s = var1a%at(3)%s * (-3)
 
 block
-  integer, volatile :: i1,i2,i3,i4
+  integer, volatile :: i1,i2,i3,i4,i5,i6
   i1 = 1
   i2 = 2
   i3 = 1
-  i4 = 2
-  !$omp target update from(var3(i1:i2)) from(var1%at(i3:i4))
+  i4 = 1
+  i5 = 2
+  i6 = 1
+  !$omp target update from(var3(i1:i2:i3)) from(var1%at(i4:i5:i6))
   i1 = 3
   i2 = 3
   i3 = 1
   i4 = 5
-  !$omp target update from(var1%at(i1)%s) from(var1%at(i2)%a(i3:i4))
+  i5 = 1
+  !$omp target update from(var1%at(i1)%s) from(var1%at(i1)%a(i3:i4:i5))
 end block
 
 if (var1 /= var1) error stop
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.