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]

[gomp4] Re: FWD: Re: OpenACC subarray specifications in the GCC Fortran front end


Hi!

On Thu, 24 Jul 2014 15:11:08 +0200, I wrote:
> On Wed, 23 Jul 2014 17:42:32 -0700, Cesar Philippidis <cesar@codesourcery.com> wrote:
> > On 07/11/2014 03:29 AM, Jakub Jelinek wrote:
> > > On Fri, Jul 11, 2014 at 12:11:10PM +0200, Thomas Schwinge wrote:
> > >> To avoid duplication of work: with Jakub's Fortran OpenMP 4 target
> > >> changes recently committed to trunk, and now merged into gomp-4_0-branch,
> > >> I have trimmed down Ilmir's patch to just the OpenACC bits, OpenMP 4
> > >> target changes removed, and TODO markers added to integrate into that.
> > > 
> > > Resolving the TODO markers would be nice, indeed.
> > 
> > This patch has the openacc data clauses use the new openmp maps. In the
> > process of doing so, I removed a lot of the old OMP_LIST_ enums and
> > added a few OMP_MAP enums to match what the c frontend currently supports.
> 
> Thanks!

> OMP_LIST_DEVICEPTR remains to be converted, which can be done as a later
> follow-up patch.

I have now committed the following to gomp-4_0-branch in r217352:

commit 779291a1fe21b3c0b0c0c615a0557f070f495d14
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Tue Nov 11 14:52:04 2014 +0000

    OpenACC deviceptr clause: Fix handling in Fortran.
    
    With two gcc_asserts restored, and not handling OpenACC deviceptr clauses in
    the same data paths as other OpenACC data clauses, we'd run into an internal
    compiler error, when the deviceptr clause is used with (non-offloaded) OpenACC
    data regions:
    
        FAIL: gfortran.dg/goacc/data-tree.f95   -O  (internal compiler error)
        FAIL: gfortran.dg/goacc/data-tree.f95   -O  (test for excess errors)
    
    	gcc/fortran/
    	* gfortran.h (OMP_LIST_DEVICEPTR): Remove, and instead...
    	(enum gfc_omp_map_op): ... add OMP_MAP_FORCE_DEVICEPTR here.
    	* dump-parse-tree.c (show_omp_clauses): Update.
    	* openmp.c (gfc_match_omp_clauses, resolve_omp_clauses)
    	(gfc_resolve_oacc_declare): Likewise.
    	* trans-openmp.c (gfc_trans_omp_clauses): Likewise.
    	gcc/
    	* omp-low.c (lower_omp_target): Restore two gcc_asserts.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@217352 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog.gomp            |  4 ++++
 gcc/fortran/ChangeLog.gomp    |  9 +++++++++
 gcc/fortran/dump-parse-tree.c |  1 -
 gcc/fortran/gfortran.h        |  6 +++---
 gcc/fortran/openmp.c          | 38 ++++++++++++++++++++++----------------
 gcc/fortran/trans-openmp.c    |  6 +++---
 gcc/omp-low.c                 |  2 ++
 7 files changed, 43 insertions(+), 23 deletions(-)

diff --git gcc/ChangeLog.gomp gcc/ChangeLog.gomp
index 9c997ce..dacfad8 100644
--- gcc/ChangeLog.gomp
+++ gcc/ChangeLog.gomp
@@ -1,3 +1,7 @@
+2014-11-11  Thomas Schwinge  <thomas@codesourcery.com>
+
+	* omp-low.c (lower_omp_target): Restore two gcc_asserts.
+
 2014-11-06  Thomas Schwinge  <thomas@codesourcery.com>
 
 	* gimple.h (is_gimple_omp_oacc_specifically): Return true for
diff --git gcc/fortran/ChangeLog.gomp gcc/fortran/ChangeLog.gomp
index d10560e..1ae1d31 100644
--- gcc/fortran/ChangeLog.gomp
+++ gcc/fortran/ChangeLog.gomp
@@ -1,3 +1,12 @@
+2014-11-11  Thomas Schwinge  <thomas@codesourcery.com>
+
+	* gfortran.h (OMP_LIST_DEVICEPTR): Remove, and instead...
+	(enum gfc_omp_map_op): ... add OMP_MAP_FORCE_DEVICEPTR here.
+	* dump-parse-tree.c (show_omp_clauses): Update.
+	* openmp.c (gfc_match_omp_clauses, resolve_omp_clauses)
+	(gfc_resolve_oacc_declare): Likewise.
+	* trans-openmp.c (gfc_trans_omp_clauses): Likewise.
+
 2014-11-05  Thomas Schwinge  <thomas@codesourcery.com>
 
 	* openmp.c (OMP_CLAUSE_HOST, OMP_CLAUSE_SELF): Merge into the new
diff --git gcc/fortran/dump-parse-tree.c gcc/fortran/dump-parse-tree.c
index 57af730..e7aff22 100644
--- gcc/fortran/dump-parse-tree.c
+++ gcc/fortran/dump-parse-tree.c
@@ -1252,7 +1252,6 @@ show_omp_clauses (gfc_omp_clauses *omp_clauses)
 	switch (list_type)
 	  {
 	  case OMP_LIST_COPY: type = "COPY"; break;
-	  case OMP_LIST_DEVICEPTR: type = "DEVICEPTR"; break;
 	  case OMP_LIST_USE_DEVICE: type = "USE_DEVICE"; break;
 	  case OMP_LIST_DEVICE_RESIDENT: type = "USE_DEVICE"; break;
 	  case OMP_LIST_CACHE: type = ""; break;
diff --git gcc/fortran/gfortran.h gcc/fortran/gfortran.h
index 6bd131c..18adbee 100644
--- gcc/fortran/gfortran.h
+++ gcc/fortran/gfortran.h
@@ -1141,7 +1141,8 @@ typedef enum
   OMP_MAP_FORCE_TO,
   OMP_MAP_FORCE_FROM,
   OMP_MAP_FORCE_TOFROM,
-  OMP_MAP_FORCE_PRESENT
+  OMP_MAP_FORCE_PRESENT,
+  OMP_MAP_FORCE_DEVICEPTR
 }
 gfc_omp_map_op;
 
@@ -1184,8 +1185,7 @@ enum
   OMP_LIST_REDUCTION,
   OMP_LIST_COPY,
   OMP_LIST_DATA_CLAUSE_FIRST = OMP_LIST_COPY,
-  OMP_LIST_DEVICEPTR,
-  OMP_LIST_DATA_CLAUSE_LAST = OMP_LIST_DEVICEPTR,
+  OMP_LIST_DATA_CLAUSE_LAST = OMP_LIST_DATA_CLAUSE_FIRST,
   OMP_LIST_DEVICE_RESIDENT,
   OMP_LIST_USE_DEVICE,
   OMP_LIST_CACHE,
diff --git gcc/fortran/openmp.c gcc/fortran/openmp.c
index 959798a..82726b8 100644
--- gcc/fortran/openmp.c
+++ gcc/fortran/openmp.c
@@ -666,10 +666,19 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, unsigned long long mask,
 				       OMP_MAP_ALLOC))
 	continue;
       if ((mask & OMP_CLAUSE_DEVICEPTR)
-	  && gfc_match_omp_variable_list ("deviceptr (",
-					  &c->lists[OMP_LIST_DEVICEPTR], true)
-	     == MATCH_YES)
-	continue;
+	  && gfc_match ("deviceptr ( ") == MATCH_YES)
+	{
+	  gfc_omp_namelist **list = &c->lists[OMP_LIST_MAP];
+	  gfc_omp_namelist **head = NULL;
+	  if (gfc_match_omp_variable_list ("", list, true, NULL, &head, false)
+	      == MATCH_YES)
+	    {
+	      gfc_omp_namelist *n;
+	      for (n = *head; n; n = n->next)
+		n->u.map_op = OMP_MAP_FORCE_DEVICEPTR;
+	      continue;
+	    }
+	}
       if ((mask & OMP_CLAUSE_USE_DEVICE)
 	  && gfc_match_omp_variable_list ("use_device (",
 					  &c->lists[OMP_LIST_USE_DEVICE], true)
@@ -2864,7 +2873,7 @@ resolve_omp_clauses (gfc_code *code, locus *where,
 	"TO", "FROM", "REDUCTION",
 	"COPY", "COPYIN", "COPYOUT", "CREATE", "DELETE", "PRESENT",
 	"PRESENT_OR_COPY", "PRESENT_OR_COPYIN", "PRESENT_OR_COPYOUT",
-	"PRESENT_OR_CREATE", "DEVICEPTR", "DEVICE_RESIDENT", "USE_DEVICE",
+	"PRESENT_OR_CREATE", "DEVICE_RESIDENT", "USE_DEVICE",
 	"HOST", "DEVICE", "CACHE" };
 
   if (omp_clauses == NULL)
@@ -3152,8 +3161,13 @@ resolve_omp_clauses (gfc_code *code, locus *where,
 		      }
 		  }
 		else if (openacc)
-		  resolve_oacc_data_clauses (n->sym, *where,
-					     clause_names[list]);
+		  {
+		    if (list == OMP_LIST_MAP
+			&& n->u.map_op == OMP_MAP_FORCE_DEVICEPTR)
+		      resolve_oacc_deviceptr_clause (n->sym, *where, name);
+		    else
+		      resolve_oacc_data_clauses (n->sym, *where, name);
+		  }
 	      }
 
 	    if (list != OMP_LIST_DEPEND)
@@ -3360,9 +3374,6 @@ resolve_omp_clauses (gfc_code *code, locus *where,
 		  case OMP_LIST_PRIVATE:
 		    gcc_assert (code && code->op != EXEC_NOP);
 		    break;
-		  case OMP_LIST_DEVICEPTR:
-		    resolve_oacc_deviceptr_clause (n->sym, *where, name);
-		    break;
 		  case OMP_LIST_USE_DEVICE:
 		      if (n->sym->attr.allocatable
 			  || (n->sym->ts.type == BT_CLASS && CLASS_DATA (n->sym)
@@ -4609,7 +4620,7 @@ gfc_resolve_oacc_declare (gfc_namespace *ns)
   locus loc;
   static const char *clause_names[] = {"COPY", "COPYIN", "COPYOUT", "CREATE",
 	"DELETE", "PRESENT", "PRESENT_OR_COPY", "PRESENT_OR_COPYIN",
-	"PRESENT_OR_COPYOUT", "PRESENT_OR_CREATE", "DEVICEPTR",
+	"PRESENT_OR_COPYOUT", "PRESENT_OR_CREATE",
 	"DEVICE_RESIDENT"};
 
   if (ns->oacc_declare_clauses == NULL)
@@ -4647,11 +4658,6 @@ gfc_resolve_oacc_declare (gfc_namespace *ns)
 	resolve_oacc_data_clauses (n->sym, loc, name);
     }
 
-  for (n = ns->oacc_declare_clauses->lists[OMP_LIST_DEVICEPTR]; n; n = n->next)
-    resolve_oacc_deviceptr_clause (n->sym, loc,
-				   clause_names[OMP_LIST_DEVICEPTR -
-						OMP_LIST_DATA_CLAUSE_FIRST]);
-
   for (n = ns->oacc_declare_clauses->lists[OMP_LIST_DEVICE_RESIDENT]; n;
        n = n->next)
     check_array_not_assumed (n->sym, loc,
diff --git gcc/fortran/trans-openmp.c gcc/fortran/trans-openmp.c
index 7dd4498..c1cf5a9 100644
--- gcc/fortran/trans-openmp.c
+++ gcc/fortran/trans-openmp.c
@@ -1765,9 +1765,6 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
 	  enum omp_clause_map_kind kind;
 	  switch (list) 
 	    {
-	    case OMP_LIST_DEVICEPTR:
-	      kind = OMP_CLAUSE_MAP_FORCE_DEVICEPTR;
-	      break;
 	    default:
 	      gcc_unreachable ();
 	    }
@@ -2164,6 +2161,9 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
 		case OMP_MAP_FORCE_PRESENT:
 		  OMP_CLAUSE_MAP_KIND (node) = OMP_CLAUSE_MAP_FORCE_PRESENT;
 		  break;
+		case OMP_MAP_FORCE_DEVICEPTR:
+		  OMP_CLAUSE_MAP_KIND (node) = OMP_CLAUSE_MAP_FORCE_DEVICEPTR;
+		  break;
 		default:
 		  gcc_unreachable ();
 		}
diff --git gcc/omp-low.c gcc/omp-low.c
index 23d9f5a8..c63ec4e 100644
--- gcc/omp-low.c
+++ gcc/omp-low.c
@@ -12044,6 +12044,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 		    && !OMP_CLAUSE_MAP_ZERO_BIAS_ARRAY_SECTION (c)
 		    && TREE_CODE (TREE_TYPE (ovar)) == ARRAY_TYPE)
 		  {
+		    gcc_assert (kind == GF_OMP_TARGET_KIND_REGION);
 		    tree avar
 		      = create_tmp_var (TREE_TYPE (TREE_TYPE (x)), NULL);
 		    mark_addressable (avar);
@@ -12054,6 +12055,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
 		  }
 		else if (is_gimple_reg (var))
 		  {
+		    gcc_assert (kind == GF_OMP_TARGET_KIND_REGION);
 		    tree avar = create_tmp_var (TREE_TYPE (var), NULL);
 		    mark_addressable (avar);
 		    enum omp_clause_map_kind map_kind


GrÃÃe,
 Thomas

Attachment: pgpZzMl9si8eM.pgp
Description: PGP signature


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