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.1] Parsing of defaultmap(tofrom:scalar) and private/firstprivate clauses on target construct


Hi!

This patch adds parsing of defaultmap(tofrom:scalar) clause as well as
allowing of private/firstprivate on target construct.

Next step will be to handle private/firstprivate in clause splitting
and gimplification rules, then expansion of firstprivate and private with
pointer-assignment on target construct and some way to pass those to the
new GOMP_target call.

2015-07-06  Jakub Jelinek  <jakub@redhat.com>

	* tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_DEFAULTMAP.
	* tree.c (omp_clause_num_ops, omp_clause_code_name): Add entries
	for defaultmap clause.
	(walk_tree_1): Handle OMP_CLAUSE_DEFAULTMAP.
	* tree-nested.c (convert_nonlocal_omp_clauses,
	convert_local_omp_clauses): Likewise.
	* tree-pretty-print.c (dump_omp_clause): Likewise.
	* gimplify.c (gimplify_scan_omp_clauses,
	gimplify_adjust_omp_clauses): Likewise.
	* omp-low.c (scan_sharing_clauses): Likewise.
c-family/
	* c-pragma.h (enum pragma_omp_clause): Add
	PRAGMA_OMP_CLAUSE_DEFAULTMAP.
c/
	* c-parser.c (c_parser_omp_clause_name): Handle defaultmap clause.
	(c_parser_omp_clause_defaultmap): New function.
	(c_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_DEFAULTMAP.
	(OMP_TARGET_CLAUSE_MASK): Add private, firstprivate and defaultmap
	clauses.
	* c-typeck.c (c_finish_omp_clauses): Handle OMP_CLAUSE_DEFAULTMAP.
	Track map, to and from clause decl uids separately from data sharing
	clauses.
cp/
	* parser.c (cp_parser_omp_clause_name): Handle defaultmap clause.
	(cp_parser_omp_clause_defaultmap): New function.
	(cp_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_DEFAULTMAP.
	(OMP_TARGET_CLAUSE_MASK): Add private, firstprivate and defaultmap
	clauses.
	* pt.c (tsubst_omp_clauses): Handle OMP_CLAUSE_HINT and
	OMP_CLAUSE_DEFAULTMAP.
	* semantics.c (finish_omp_clauses): Handle OMP_CLAUSE_DEFAULTMAP.
	Track map, to and from clause decl uids separately from data sharing
	clauses.

--- gcc/tree-core.h.jj	2015-06-30 14:26:04.000000000 +0200
+++ gcc/tree-core.h	2015-07-06 11:40:33.662330075 +0200
@@ -391,6 +391,9 @@ enum omp_clause_code {
   /* OpenMP clause: hint (integer-expression).  */
   OMP_CLAUSE_HINT,
 
+  /* OpenMP clause: defaultmap (tofrom: scalar).  */
+  OMP_CLAUSE_DEFAULTMAP,
+
   /* Internally used only clause, holding SIMD uid.  */
   OMP_CLAUSE__SIMDUID_,
 
--- gcc/tree.c.jj	2015-06-30 14:24:42.000000000 +0200
+++ gcc/tree.c	2015-07-06 11:49:14.359071514 +0200
@@ -343,6 +343,7 @@ unsigned const char omp_clause_num_ops[]
   0, /* OMP_CLAUSE_THREADS  */
   0, /* OMP_CLAUSE_SIMD  */
   1, /* OMP_CLAUSE_HINT  */
+  0, /* OMP_CLAUSE_DEFALTMAP  */
   1, /* OMP_CLAUSE__SIMDUID_  */
   1, /* OMP_CLAUSE__CILK_FOR_COUNT_  */
   0, /* OMP_CLAUSE_INDEPENDENT  */
@@ -409,6 +410,7 @@ const char * const omp_clause_code_name[
   "threads",
   "simd",
   "hint",
+  "defaultmap",
   "_simduid_",
   "_Cilk_for_count_",
   "independent",
@@ -11405,6 +11407,7 @@ walk_tree_1 (tree *tp, walk_tree_fn func
 	case OMP_CLAUSE_NOGROUP:
 	case OMP_CLAUSE_THREADS:
 	case OMP_CLAUSE_SIMD:
+	case OMP_CLAUSE_DEFAULTMAP:
 	case OMP_CLAUSE_AUTO:
 	case OMP_CLAUSE_SEQ:
 	  WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (*tp));
--- gcc/tree-nested.c.jj	2015-06-30 14:25:59.000000000 +0200
+++ gcc/tree-nested.c	2015-07-06 12:00:48.230411331 +0200
@@ -1202,6 +1202,7 @@ convert_nonlocal_omp_clauses (tree *pcla
 	case OMP_CLAUSE_NOGROUP:
 	case OMP_CLAUSE_THREADS:
 	case OMP_CLAUSE_SIMD:
+	case OMP_CLAUSE_DEFAULTMAP:
 	  break;
 
 	default:
@@ -1854,6 +1855,7 @@ convert_local_omp_clauses (tree *pclause
 	case OMP_CLAUSE_NOGROUP:
 	case OMP_CLAUSE_THREADS:
 	case OMP_CLAUSE_SIMD:
+	case OMP_CLAUSE_DEFAULTMAP:
 	  break;
 
 	default:
--- gcc/tree-pretty-print.c.jj	2015-06-30 14:24:29.000000000 +0200
+++ gcc/tree-pretty-print.c	2015-07-06 12:01:47.048592456 +0200
@@ -733,6 +733,10 @@ dump_omp_clause (pretty_printer *pp, tre
       pp_right_paren (pp);
       break;
 
+    case OMP_CLAUSE_DEFAULTMAP:
+      pp_string (pp, "defaultmap(tofrom:scalar)");
+      break;
+
     case OMP_CLAUSE__SIMDUID_:
       pp_string (pp, "_simduid_(");
       dump_generic_node (pp, OMP_CLAUSE__SIMDUID__DECL (clause),
--- gcc/gimplify.c.jj	2015-06-30 14:25:45.000000000 +0200
+++ gcc/gimplify.c	2015-07-06 11:42:21.846820653 +0200
@@ -6606,6 +6606,7 @@ gimplify_scan_omp_clauses (tree *list_p,
 	case OMP_CLAUSE_NOGROUP:
 	case OMP_CLAUSE_THREADS:
 	case OMP_CLAUSE_SIMD:
+	case OMP_CLAUSE_DEFAULTMAP:
 	  break;
 
 	case OMP_CLAUSE_ALIGNED:
@@ -6965,6 +6966,7 @@ gimplify_adjust_omp_clauses (gimple_seq
 	case OMP_CLAUSE_THREADS:
 	case OMP_CLAUSE_SIMD:
 	case OMP_CLAUSE_HINT:
+	case OMP_CLAUSE_DEFAULTMAP:
 	case OMP_CLAUSE__CILK_FOR_COUNT_:
 	case OMP_CLAUSE_ASYNC:
 	case OMP_CLAUSE_WAIT:
--- gcc/omp-low.c.jj	2015-07-02 09:27:03.000000000 +0200
+++ gcc/omp-low.c	2015-07-06 19:36:01.730839081 +0200
@@ -2100,6 +2100,7 @@ scan_sharing_clauses (tree clauses, omp_
 	case OMP_CLAUSE_THREADS:
 	case OMP_CLAUSE_SIMD:
 	case OMP_CLAUSE_NOGROUP:
+	case OMP_CLAUSE_DEFAULTMAP:
 	case OMP_CLAUSE_ASYNC:
 	case OMP_CLAUSE_WAIT:
 	case OMP_CLAUSE_GANG:
@@ -2255,6 +2256,7 @@ scan_sharing_clauses (tree clauses, omp_
 	case OMP_CLAUSE_THREADS:
 	case OMP_CLAUSE_SIMD:
 	case OMP_CLAUSE_NOGROUP:
+	case OMP_CLAUSE_DEFAULTMAP:
 	case OMP_CLAUSE__CILK_FOR_COUNT_:
 	case OMP_CLAUSE_ASYNC:
 	case OMP_CLAUSE_WAIT:
--- gcc/c-family/c-pragma.h.jj	2015-06-12 15:51:05.000000000 +0200
+++ gcc/c-family/c-pragma.h	2015-07-06 11:36:55.094379598 +0200
@@ -86,6 +86,7 @@ typedef enum pragma_omp_clause {
   PRAGMA_OMP_CLAUSE_COPYIN,
   PRAGMA_OMP_CLAUSE_COPYPRIVATE,
   PRAGMA_OMP_CLAUSE_DEFAULT,
+  PRAGMA_OMP_CLAUSE_DEFAULTMAP,
   PRAGMA_OMP_CLAUSE_DEPEND,
   PRAGMA_OMP_CLAUSE_DEVICE,
   PRAGMA_OMP_CLAUSE_DIST_SCHEDULE,
--- gcc/c/c-parser.c.jj	2015-07-01 13:01:23.000000000 +0200
+++ gcc/c/c-parser.c	2015-07-06 13:42:51.874455637 +0200
@@ -9910,7 +9910,9 @@ c_parser_omp_clause_name (c_parser *pars
 	    result = PRAGMA_OACC_CLAUSE_CREATE;
 	  break;
 	case 'd':
-	  if (!strcmp ("delete", p))
+	  if (!strcmp ("defaultmap", p))
+	    result = PRAGMA_OMP_CLAUSE_DEFAULTMAP;
+	  else if (!strcmp ("delete", p))
 	    result = PRAGMA_OACC_CLAUSE_DELETE;
 	  else if (!strcmp ("depend", p))
 	    result = PRAGMA_OMP_CLAUSE_DEPEND;
@@ -10866,6 +10868,55 @@ c_parser_omp_clause_hint (c_parser *pars
   return list;
 }
 
+/* OpenMP 4.1:
+   defaultmap ( tofrom : scalar ) */
+
+static tree
+c_parser_omp_clause_defaultmap (c_parser *parser, tree list)
+{
+  location_t loc = c_parser_peek_token (parser)->location;
+  tree c;
+  const char *p;
+
+  if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
+    return list;
+  if (!c_parser_next_token_is (parser, CPP_NAME))
+    {
+      c_parser_error (parser, "expected %<tofrom%>");
+      goto out_err;
+    }
+  p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
+  if (strcmp (p, "tofrom") != 0)
+    {
+      c_parser_error (parser, "expected %<tofrom%>");
+      goto out_err;
+    }
+  c_parser_consume_token (parser);
+  if (!c_parser_require (parser, CPP_COLON, "expected %<:%>"))
+    goto out_err;
+  if (!c_parser_next_token_is (parser, CPP_NAME))
+    {
+      c_parser_error (parser, "expected %<scalar%>");
+      goto out_err;
+    }
+  p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
+  if (strcmp (p, "scalar") != 0)
+    {
+      c_parser_error (parser, "expected %<scalar%>");
+      goto out_err;
+    }
+  c_parser_consume_token (parser);
+  c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>");
+  check_no_duplicate_clause (list, OMP_CLAUSE_DEFAULTMAP, "defaultmap");
+  c = build_omp_clause (loc, OMP_CLAUSE_DEFAULTMAP);
+  OMP_CLAUSE_CHAIN (c) = list;
+  return c;
+
+ out_err:
+  c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>");
+  return list;
+}
+
 /* OpenACC:
    num_workers ( expression ) */
 
@@ -12210,6 +12261,10 @@ c_parser_omp_all_clauses (c_parser *pars
 	  clauses = c_parser_omp_clause_hint (parser, clauses);
 	  c_name = "hint";
 	  break;
+	case PRAGMA_OMP_CLAUSE_DEFAULTMAP:
+	  clauses = c_parser_omp_clause_defaultmap (parser, clauses);
+	  c_name = "defaultmap";
+	  break;
 	case PRAGMA_OMP_CLAUSE_IF:
 	  clauses = c_parser_omp_clause_if (parser, clauses);
 	  c_name = "if";
@@ -14607,7 +14662,10 @@ c_parser_omp_target_exit_data (location_
 	| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_MAP)		\
 	| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IF)		\
 	| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEPEND)	\
-	| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT))
+	| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT)	\
+	| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_PRIVATE)	\
+	| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_FIRSTPRIVATE)	\
+	| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEFAULTMAP))
 
 static bool
 c_parser_omp_target (c_parser *parser, enum pragma_context context)
--- gcc/c/c-typeck.c.jj	2015-07-01 12:50:49.000000000 +0200
+++ gcc/c/c-typeck.c	2015-07-06 19:04:23.357814307 +0200
@@ -12101,7 +12101,7 @@ tree
 c_finish_omp_clauses (tree clauses, bool declare_simd)
 {
   bitmap_head generic_head, firstprivate_head, lastprivate_head;
-  bitmap_head aligned_head;
+  bitmap_head aligned_head, map_head;
   tree c, t, type, *pc;
   tree simdlen = NULL_TREE, safelen = NULL_TREE;
   bool branch_seen = false;
@@ -12113,6 +12113,7 @@ c_finish_omp_clauses (tree clauses, bool
   bitmap_initialize (&firstprivate_head, &bitmap_default_obstack);
   bitmap_initialize (&lastprivate_head, &bitmap_default_obstack);
   bitmap_initialize (&aligned_head, &bitmap_default_obstack);
+  bitmap_initialize (&map_head, &bitmap_default_obstack);
 
   for (pc = &clauses, c = clauses; c ; c = *pc)
     {
@@ -12559,7 +12560,7 @@ c_finish_omp_clauses (tree clauses, bool
 			omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
 	      remove = true;
 	    }
-	  else if (bitmap_bit_p (&generic_head, DECL_UID (t)))
+	  else if (bitmap_bit_p (&map_head, DECL_UID (t)))
 	    {
 	      if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP)
 		error ("%qD appears more than once in motion clauses", t);
@@ -12568,7 +12569,7 @@ c_finish_omp_clauses (tree clauses, bool
 	      remove = true;
 	    }
 	  else
-	    bitmap_set_bit (&generic_head, DECL_UID (t));
+	    bitmap_set_bit (&map_head, DECL_UID (t));
 	  break;
 
 	case OMP_CLAUSE_UNIFORM:
@@ -12624,6 +12625,7 @@ c_finish_omp_clauses (tree clauses, bool
 	case OMP_CLAUSE_THREADS:
 	case OMP_CLAUSE_SIMD:
 	case OMP_CLAUSE_HINT:
+	case OMP_CLAUSE_DEFAULTMAP:
 	case OMP_CLAUSE__CILK_FOR_COUNT_:
 	case OMP_CLAUSE_NUM_GANGS:
 	case OMP_CLAUSE_NUM_WORKERS:
--- gcc/cp/parser.c.jj	2015-07-02 09:29:23.000000000 +0200
+++ gcc/cp/parser.c	2015-07-06 13:42:22.264865920 +0200
@@ -27683,7 +27683,9 @@ cp_parser_omp_clause_name (cp_parser *pa
 	    result = PRAGMA_OACC_CLAUSE_CREATE;
 	  break;
 	case 'd':
-	  if (!strcmp ("depend", p))
+	  if (!strcmp ("defaultmap", p))
+	    result = PRAGMA_OMP_CLAUSE_DEFAULTMAP;
+	  else if (!strcmp ("depend", p))
 	    result = PRAGMA_OMP_CLAUSE_DEPEND;
 	  else if (!strcmp ("device", p))
 	    result = PRAGMA_OMP_CLAUSE_DEVICE;
@@ -28605,6 +28607,65 @@ cp_parser_omp_clause_hint (cp_parser *pa
   return c;
 }
 
+/* OpenMP 4.1:
+   defaultmap ( tofrom : scalar ) */
+
+static tree
+cp_parser_omp_clause_defaultmap (cp_parser *parser, tree list,
+				 location_t location)
+{
+  tree c, id;
+  const char *p;
+
+  if (!cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN))
+    return list;
+
+  if (!cp_lexer_next_token_is (parser->lexer, CPP_NAME))
+    {
+      cp_parser_error (parser, "expected %<tofrom%>");
+      goto out_err;
+    }
+  id = cp_lexer_peek_token (parser->lexer)->u.value;
+  p = IDENTIFIER_POINTER (id);
+  if (strcmp (p, "tofrom") != 0)
+    {
+      cp_parser_error (parser, "expected %<tofrom%>");
+      goto out_err;
+    }
+  cp_lexer_consume_token (parser->lexer);
+  if (!cp_parser_require (parser, CPP_COLON, RT_COLON))
+    goto out_err;
+
+  if (!cp_lexer_next_token_is (parser->lexer, CPP_NAME))
+    {
+      cp_parser_error (parser, "expected %<scalar%>");
+      goto out_err;
+    }
+  id = cp_lexer_peek_token (parser->lexer)->u.value;
+  p = IDENTIFIER_POINTER (id);
+  if (strcmp (p, "scalar") != 0)
+    {
+      cp_parser_error (parser, "expected %<scalar%>");
+      goto out_err;
+    }
+  cp_lexer_consume_token (parser->lexer);
+  if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN))
+    goto out_err;
+
+  check_no_duplicate_clause (list, OMP_CLAUSE_DEFAULTMAP, "defaultmap",
+			     location);
+
+  c = build_omp_clause (location, OMP_CLAUSE_DEFAULTMAP);
+  OMP_CLAUSE_CHAIN (c) = list;
+  return c;
+
+ out_err:
+  cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true,
+					 /*or_comma=*/false,
+					 /*consume_paren=*/true);
+  return list;
+}
+
 /* OpenACC:
    num_workers ( expression ) */
 
@@ -29750,6 +29811,11 @@ cp_parser_omp_all_clauses (cp_parser *pa
 					       token->location);
 	  c_name = "hint";
 	  break;
+	case PRAGMA_OMP_CLAUSE_DEFAULTMAP:
+	  clauses = cp_parser_omp_clause_defaultmap (parser, clauses,
+						     token->location);
+	  c_name = "defaultmap";
+	  break;
 	case PRAGMA_OMP_CLAUSE_IF:
 	  clauses = cp_parser_omp_clause_if (parser, clauses, token->location);
 	  c_name = "if";
@@ -32187,7 +32253,10 @@ cp_parser_omp_target_update (cp_parser *
 	| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_MAP)		\
 	| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IF)		\
 	| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEPEND)	\
-	| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT))
+	| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT)	\
+	| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_PRIVATE)	\
+	| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_FIRSTPRIVATE)	\
+	| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEFAULTMAP))
 
 static bool
 cp_parser_omp_target (cp_parser *parser, cp_token *pragma_tok,
--- gcc/cp/pt.c.jj	2015-07-01 12:50:50.000000000 +0200
+++ gcc/cp/pt.c	2015-07-06 13:23:11.283816797 +0200
@@ -13617,6 +13617,7 @@ tsubst_omp_clauses (tree clauses, bool d
 	case OMP_CLAUSE_GRAINSIZE:
 	case OMP_CLAUSE_PRIORITY:
 	case OMP_CLAUSE_ORDERED:
+	case OMP_CLAUSE_HINT:
 	  OMP_CLAUSE_OPERAND (nc, 0)
 	    = tsubst_expr (OMP_CLAUSE_OPERAND (oc, 0), args, complain, 
 			   in_decl, /*integral_constant_expression_p=*/false);
@@ -13670,6 +13671,7 @@ tsubst_omp_clauses (tree clauses, bool d
 	case OMP_CLAUSE_NOGROUP:
 	case OMP_CLAUSE_THREADS:
 	case OMP_CLAUSE_SIMD:
+	case OMP_CLAUSE_DEFAULTMAP:
 	  break;
 	default:
 	  gcc_unreachable ();
--- gcc/cp/semantics.c.jj	2015-07-01 12:50:50.000000000 +0200
+++ gcc/cp/semantics.c	2015-07-06 19:20:51.087293030 +0200
@@ -5498,7 +5498,7 @@ tree
 finish_omp_clauses (tree clauses, bool allow_fields, bool declare_simd)
 {
   bitmap_head generic_head, firstprivate_head, lastprivate_head;
-  bitmap_head aligned_head;
+  bitmap_head aligned_head, map_head;
   tree c, t, *pc;
   tree safelen = NULL_TREE;
   bool branch_seen = false;
@@ -5509,6 +5509,7 @@ finish_omp_clauses (tree clauses, bool a
   bitmap_initialize (&firstprivate_head, &bitmap_default_obstack);
   bitmap_initialize (&lastprivate_head, &bitmap_default_obstack);
   bitmap_initialize (&aligned_head, &bitmap_default_obstack);
+  bitmap_initialize (&map_head, &bitmap_default_obstack);
 
   for (pc = &clauses, c = clauses; c ; c = *pc)
     {
@@ -6155,7 +6156,7 @@ finish_omp_clauses (tree clauses, bool a
 			omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
 	      remove = true;
 	    }
-	  else if (bitmap_bit_p (&generic_head, DECL_UID (t)))
+	  else if (bitmap_bit_p (&map_head, DECL_UID (t)))
 	    {
 	      if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP)
 		error ("%qD appears more than once in motion clauses", t);
@@ -6164,7 +6165,7 @@ finish_omp_clauses (tree clauses, bool a
 	      remove = true;
 	    }
 	  else
-	    bitmap_set_bit (&generic_head, DECL_UID (t));
+	    bitmap_set_bit (&map_head, DECL_UID (t));
 	  break;
 
 	case OMP_CLAUSE_UNIFORM:
@@ -6305,6 +6306,7 @@ finish_omp_clauses (tree clauses, bool a
 	case OMP_CLAUSE_NOGROUP:
 	case OMP_CLAUSE_THREADS:
 	case OMP_CLAUSE_SIMD:
+	case OMP_CLAUSE_DEFAULTMAP:
 	case OMP_CLAUSE__CILK_FOR_COUNT_:
 	  break;
 

	Jakub


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