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] acc self/host/device clauses


This patch updates how the OpenACC device, self and host clauses are
handled in gfortan. Specifically these clauses now map to
OMP_MAP_FORCE_TO (host) and OMP_MAP_FORCE_FROM (device and self) in a
similar fashion to the c/c++ front ends.

I've also included a minor cleanup to
gfc_trans_oacc_executable_directive. That function no longer gets called
to process the wait directive, so I made that function aware of that.
The wait patch still has not been checked in yet because it depends on
some middle end support which hasn't gone into gomp-4_0-branch yet.
Therefore, I'll hold of committing this patch until the wait patch goes in.

It this OK for gomp-4_0-branch?

Thanks,
Cesar
2014-10-20  Cesar Philippidis  <cesar@codesourcery.com>

	gcc/fortran/
	* gfortran.h (enum OMP_LIST_HOST): Remove.
	(enum OMP_LIST_DEVICE): Remove.
	* dump-parse-tree.c (show_omp_clauses): Remove OMP_LIST_HOST and
	OMP_LIST_DEVICE from here also.
	* openmp.c (OMP_CLAUSE_SELF): New define.
	(gfc_match_omp_clauses): Update handling of OMP_CLAUSE_HOST and
	OMP_CLAUSE_DEVICE. Add support for OMP_CLAUSE_SELF.
	* trans-openmp.c (gfc_trans_omp_clauses): Remove support for
	OMP_LIST_HOST and OMP_LIST_DEVICE since they are treated as memory
	maps now.
	(gfc_trans_oacc_executable_directive): Remove stale EXEC_OACC_WAIT.


diff --git a/gcc/fortran/dump-parse-tree.c b/gcc/fortran/dump-parse-tree.c
index f85f6b6..57af730 100644
--- a/gcc/fortran/dump-parse-tree.c
+++ b/gcc/fortran/dump-parse-tree.c
@@ -1255,8 +1255,6 @@ show_omp_clauses (gfc_omp_clauses *omp_clauses)
 	  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_HOST: type = "HOST"; break;
-	  case OMP_LIST_DEVICE: type = "DEVICE"; break;
 	  case OMP_LIST_CACHE: type = ""; break;
 	  case OMP_LIST_PRIVATE: type = "PRIVATE"; break;
 	  case OMP_LIST_FIRSTPRIVATE: type = "FIRSTPRIVATE"; break;
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index cdcd002..42afdc9 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -1188,8 +1188,6 @@ enum
   OMP_LIST_DATA_CLAUSE_LAST = OMP_LIST_DEVICEPTR,
   OMP_LIST_DEVICE_RESIDENT,
   OMP_LIST_USE_DEVICE,
-  OMP_LIST_HOST,
-  OMP_LIST_DEVICE,
   OMP_LIST_CACHE,
   OMP_LIST_NUM,
   OMP_LIST_LAST = OMP_LIST_NUM
diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c
index 1970730..c7af004 100644
--- a/gcc/fortran/openmp.c
+++ b/gcc/fortran/openmp.c
@@ -451,6 +451,7 @@ match_oacc_clause_gang (gfc_omp_clauses *cp)
 #define OMP_CLAUSE_DELETE		(1ULL << 55)
 #define OMP_CLAUSE_AUTO			(1ULL << 56)
 #define OMP_CLAUSE_TILE			(1ULL << 57)
+#define OMP_CLAUSE_SELF			(1ULL << 58)
 
 /* Helper function for OpenACC and OpenMP clauses involving memory
    mapping.  */
@@ -682,18 +683,23 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, unsigned long long mask,
 	     == MATCH_YES)
 	continue;
       if ((mask & OMP_CLAUSE_HOST)
-	  && gfc_match_omp_variable_list ("host (",
-					  &c->lists[OMP_LIST_HOST], true)
-	     == MATCH_YES)
+	  && gfc_match ("host ( ") == MATCH_YES
+	  && gfc_match_omp_map_clause (&c->lists[OMP_LIST_MAP],
+				       OMP_MAP_FORCE_FROM))
 	continue;
       if ((mask & OMP_CLAUSE_OACC_DEVICE)
-	  && gfc_match_omp_variable_list ("device (",
-					  &c->lists[OMP_LIST_DEVICE], true)
-	     == MATCH_YES)
+	  && gfc_match ("device ( ") == MATCH_YES
+	  && gfc_match_omp_map_clause (&c->lists[OMP_LIST_MAP],
+				       OMP_MAP_FORCE_TO))
 	continue;
       if ((mask & OMP_CLAUSE_TILE)
 	  && match_oacc_expr_list ("tile (", &c->tile_list, true) == MATCH_YES)
 	continue;
+      if ((mask & OMP_CLAUSE_SELF)
+	  && gfc_match ("self ( ") == MATCH_YES
+	  && gfc_match_omp_map_clause (&c->lists[OMP_LIST_MAP],
+				       OMP_MAP_FORCE_FROM))
+	continue;
       if ((mask & OMP_CLAUSE_SEQ) && !c->seq
 	  && gfc_match ("seq") == MATCH_YES)
 	{
@@ -1164,7 +1170,8 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, unsigned long long mask,
    | OMP_CLAUSE_PRESENT_OR_COPYIN | OMP_CLAUSE_PRESENT_OR_COPYOUT             \
    | OMP_CLAUSE_PRESENT_OR_CREATE)
 #define OACC_UPDATE_CLAUSES \
-  (OMP_CLAUSE_IF | OMP_CLAUSE_ASYNC | OMP_CLAUSE_HOST | OMP_CLAUSE_OACC_DEVICE)
+  (OMP_CLAUSE_IF | OMP_CLAUSE_ASYNC | OMP_CLAUSE_HOST | OMP_CLAUSE_SELF \
+   | OMP_CLAUSE_OACC_DEVICE | OMP_CLAUSE_WAIT)
 #define OACC_ENTER_DATA_CLAUSES \
   (OMP_CLAUSE_IF | OMP_CLAUSE_ASYNC | OMP_CLAUSE_WAIT | OMP_CLAUSE_COPYIN    \
    | OMP_CLAUSE_CREATE | OMP_CLAUSE_PRESENT_OR_COPYIN                          \
diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c
index 23628e8..ce97dc4 100644
--- a/gcc/fortran/trans-openmp.c
+++ b/gcc/fortran/trans-openmp.c
@@ -1796,12 +1796,6 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
 	case OMP_LIST_DEVICE_RESIDENT:
 	  clause_code = OMP_CLAUSE_DEVICE_RESIDENT;
 	  goto add_clause;
-	case OMP_LIST_HOST:
-	  clause_code = OMP_CLAUSE_HOST;
-	  goto add_clause;
-	case OMP_LIST_DEVICE:
-	  clause_code = OMP_CLAUSE_OACC_DEVICE;
-	  goto add_clause;
 	case OMP_LIST_CACHE:
 	  clause_code = OMP_NO_CLAUSE_CACHE;
 	  goto add_clause;
@@ -2548,17 +2542,14 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
   if (clauses->wait_list)
     {
       gfc_expr_list *el;
-      tree list = NULL;
 
       for (el = clauses->wait_list; el; el = el->next)
 	{
 	  c = build_omp_clause (where.lb->location, OMP_CLAUSE_WAIT);
 	  OMP_CLAUSE_DECL (c) = gfc_convert_expr_to_tree (block, el->expr);
-	  OMP_CLAUSE_CHAIN (c) = list;
-	  list = c;
+	  OMP_CLAUSE_CHAIN (c) = omp_clauses;
+	  omp_clauses = c;
 	}
-
-      omp_clauses = list;
     }
   if (clauses->num_gangs_expr)
     {
@@ -2716,9 +2707,6 @@ gfc_trans_oacc_executable_directive (gfc_code *code)
       case EXEC_OACC_EXIT_DATA:
 	construct_code = OACC_EXIT_DATA;
 	break;
-      case EXEC_OACC_WAIT:
-	construct_code = OACC_WAIT;
-	break;
       case EXEC_OACC_CACHE:
 	construct_code = OACC_CACHE;
 	break;

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