This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] allow deferred-shape pointers in OpenACC data clauses


This patch teaches the fortran FE to allow deferred-shape pointers to be
used in OpenACC data clauses. While the spec states that arrays must be
contiguous, I believe that is a run-time requirement, not a compile
time. The intent behind OpenACC is to have the programmer sprinkle a
minimum amount of ACC directives on their existing code base, and have
the compiler generate offloading code. In this case, the deferred-shape
pointer check was preventing working code from compiling.

I was considering relaxing the error to a warning, but I ended up
deciding this should be a run-time failure, if there is one.

Is this OK for trunk? I tested it on x86_64 with nvptx offloading.

Cesar

2017-07-14  Cesar Philippidis  <cesar@codesourcery.com>

	gcc/fortran/
	* openmp.c (check_array_not_assumed): Don't error on noncontiguous
	deferred-shape pointers.

	gcc/testsuite/
	* gfortran.dg/goacc/deferred-shape-pointer.f90: New test.


diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c
index 8400354181c..f08a37e0d89 100644
--- a/gcc/fortran/openmp.c
+++ b/gcc/fortran/openmp.c
@@ -3774,10 +3774,6 @@ check_array_not_assumed (gfc_symbol *sym, locus loc, const char *name)
   if (sym->as && sym->as->type == AS_ASSUMED_RANK)
     gfc_error ("Assumed rank array %qs in %s clause at %L",
 	       sym->name, name, &loc);
-  if (sym->as && sym->as->type == AS_DEFERRED && sym->attr.pointer
-      && !sym->attr.contiguous)
-    gfc_error ("Noncontiguous deferred shape array %qs in %s clause at %L",
-	       sym->name, name, &loc);
 }
 
 static void
diff --git a/gcc/testsuite/gfortran.dg/goacc/deferred-shape-pointer.f90 b/gcc/testsuite/gfortran.dg/goacc/deferred-shape-pointer.f90
new file mode 100644
index 00000000000..e0d0b8dd916
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc/deferred-shape-pointer.f90
@@ -0,0 +1,20 @@
+! Test support of deferred-shape pointers.
+
+subroutine foo (x, y, z)
+  implicit none
+
+  integer :: y, z, i
+  integer,target :: x(y:z)
+  integer, pointer, dimension(:) :: px
+
+  px => x
+
+  !$acc data present(px)
+  !$acc end data
+
+  !$acc parallel loop present(px)
+  do i = 1, z
+     px(i) = px(i) * 2
+  end do
+  !$acc end parallel loop
+end subroutine foo

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]