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]

[gomp] Add firstprivatization langhook


Hi!

This langhook saves copying of about 30 variables at the end of each
parallel on vla*.f90 tests.
The artificial vars used there are written just once and afterwards
not stay unchanged.
Ok for gomp?

2005-11-07  Jakub Jelinek  <jakub@redhat.com>

	* langhooks.h (struct lang_hooks_for_types): Add
	omp_firstprivatize_type_sizes hook.
	* langhooks.c (lhd_omp_firstprivatize_type_sizes): New function.
	* langhooks-def.h (lhd_omp_firstprivatize_type_sizes): New prototype.
	(LANG_HOOKS_OMP_FIRSTPRIVATIZE_TYPE_SIZES): Define.
	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add
	LANG_HOOKS_OMP_FIRSTPRIVATIZE_TYPE_SIZES.
	* gimplify.c (omp_firstprivatize_variable): No longer static.
	(omp_firstprivatize_type_sizes): Call omp_firstprivatize_type_sizes
	langhook.
	* tree-gimple.h (omp_firstprivatize_variable): New prototype.
fortran/
	* trans-openmp.c (gfc_omp_firstprivatize_type_sizes): New function.
	* f95-lang.c (LANG_HOOKS_OMP_FIRSTPRIVATIZE_TYPE_SIZES): Define.
	* trans.h (gfc_omp_firstprivatize_type_sizes): New prototype.

--- gcc/langhooks.h.jj	2005-11-01 20:04:50.000000000 +0100
+++ gcc/langhooks.h	2005-11-07 10:03:16.000000000 +0100
@@ -25,6 +25,8 @@ Boston, MA 02110-1301, USA.  */
 
 struct diagnostic_context;
 
+struct gimplify_omp_ctx;
+
 /* A print hook for print_tree ().  */
 typedef void (*lang_print_tree_hook) (FILE *, tree, int indent);
 
@@ -142,6 +144,10 @@ struct lang_hooks_for_types
      for a type.  */
   tree (*max_size) (tree);
 
+  /* Register language specific type size variables as potentially OpenMP
+     firstprivate variables.  */
+  void (*omp_firstprivatize_type_sizes) (struct gimplify_omp_ctx *, tree);
+
   /* Nonzero if types that are identical are to be hashed so that only
      one copy is kept.  If a language requires unique types for each
      user-specified type, such as Ada, this should be set to TRUE.  */
--- gcc/langhooks.c.jj	2005-10-31 09:43:13.000000000 +0100
+++ gcc/langhooks.c	2005-11-07 10:04:22.000000000 +0100
@@ -567,3 +567,12 @@ lhd_omp_assignment (tree clause ATTRIBUT
 {
   return build2 (MODIFY_EXPR, void_type_node, dst, src);
 }
+
+/* Register language specific type size variables as potentially OpenMP
+   firstprivate variables.  */
+
+void
+lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *c ATTRIBUTE_UNUSED,
+				   tree t ATTRIBUTE_UNUSED)
+{
+}
--- gcc/langhooks-def.h.jj	2005-11-01 20:03:57.000000000 +0100
+++ gcc/langhooks-def.h	2005-11-07 10:37:51.000000000 +0100
@@ -90,6 +90,9 @@ extern tree lhd_callgraph_analyze_expr (
 extern int lhd_gimplify_expr (tree *, tree *, tree *);
 extern enum omp_clause_default_kind lhd_omp_predetermined_sharing (tree);
 extern tree lhd_omp_assignment (tree, tree, tree);
+struct gimplify_omp_ctx;
+extern void lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *,
+					       tree);
 
 #define LANG_HOOKS_NAME			"GNU unknown"
 #define LANG_HOOKS_IDENTIFIER_SIZE	sizeof (struct lang_identifier)
@@ -215,6 +218,8 @@ extern tree lhd_make_node (enum tree_cod
 #define LANG_HOOKS_TYPE_PROMOTES_TO lhd_type_promotes_to
 #define LANG_HOOKS_REGISTER_BUILTIN_TYPE lhd_register_builtin_type
 #define LANG_HOOKS_TYPE_MAX_SIZE	lhd_return_null_tree
+#define LANG_HOOKS_OMP_FIRSTPRIVATIZE_TYPE_SIZES \
+  lhd_omp_firstprivatize_type_sizes
 #define LANG_HOOKS_HASH_TYPES		true
 
 #define LANG_HOOKS_FOR_TYPES_INITIALIZER { \
@@ -228,6 +233,7 @@ extern tree lhd_make_node (enum tree_cod
   LANG_HOOKS_REGISTER_BUILTIN_TYPE, \
   LANG_HOOKS_INCOMPLETE_TYPE_ERROR, \
   LANG_HOOKS_TYPE_MAX_SIZE, \
+  LANG_HOOKS_OMP_FIRSTPRIVATIZE_TYPE_SIZES, \
   LANG_HOOKS_HASH_TYPES \
 }
 
--- gcc/tree-gimple.h.jj	2005-11-06 00:29:55.000000000 +0100
+++ gcc/tree-gimple.h	2005-11-07 10:34:21.000000000 +0100
@@ -128,6 +128,8 @@ extern tree alloc_stmt_list (void);
 extern void free_stmt_list (tree);
 extern tree force_labels_r (tree *, int *, void *);
 extern enum gimplify_status gimplify_va_arg_expr (tree *, tree *, tree *);
+struct gimplify_omp_ctx;
+extern void omp_firstprivatize_variable (struct gimplify_omp_ctx *, tree);
 
 /* In omp-low.c.  */
 extern tree find_omp_clause (tree, enum tree_code);
--- gcc/gimplify.c.jj	2005-11-06 00:35:02.000000000 +0100
+++ gcc/gimplify.c	2005-11-07 09:59:40.000000000 +0100
@@ -4121,7 +4121,7 @@ gimplify_to_stmt_list (tree *stmt_p)
    to CTX.  If entries already exist, force them to be some flavor of private.
    If there is no enclosing parallel, do nothing.  */
 
-static void
+void
 omp_firstprivatize_variable (struct gimplify_omp_ctx *ctx, tree decl)
 {
   splay_tree_node n;
@@ -4200,6 +4200,7 @@ omp_firstprivatize_type_sizes (struct gi
 
   omp_firstprivatize_variable (ctx, TYPE_SIZE (type));
   omp_firstprivatize_variable (ctx, TYPE_SIZE_UNIT (type));
+  lang_hooks.types.omp_firstprivatize_type_sizes (ctx, type);
 }
 
 /* Add an entry for DECL in the OpenMP context CTX with FLAGS.  */
--- gcc/fortran/trans-openmp.c.jj	2005-11-06 00:29:55.000000000 +0100
+++ gcc/fortran/trans-openmp.c	2005-11-07 10:18:45.000000000 +0100
@@ -142,6 +142,28 @@ gfc_omp_private_debug_clause (tree decl,
   return false;
 }
 
+/* Register language specific type size variables as potentially OpenMP
+   firstprivate variables.  */
+
+void
+gfc_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *ctx, tree type)
+{
+  if (GFC_ARRAY_TYPE_P (type) || GFC_DESCRIPTOR_TYPE_P (type))
+    {
+      int r;
+
+      gcc_assert (TYPE_LANG_SPECIFIC (type) != NULL);
+      for (r = 0; r < GFC_TYPE_ARRAY_RANK (type); r++)
+	{
+	  omp_firstprivatize_variable (ctx, GFC_TYPE_ARRAY_LBOUND (type, r));
+	  omp_firstprivatize_variable (ctx, GFC_TYPE_ARRAY_UBOUND (type, r));
+	  omp_firstprivatize_variable (ctx, GFC_TYPE_ARRAY_STRIDE (type, r));
+	}
+      omp_firstprivatize_variable (ctx, GFC_TYPE_ARRAY_SIZE (type));
+      omp_firstprivatize_variable (ctx, GFC_TYPE_ARRAY_OFFSET (type));
+    }
+}
+
 
 static inline tree
 gfc_trans_add_clause (tree node, tree tail)
--- gcc/fortran/f95-lang.c.jj	2005-11-01 20:01:13.000000000 +0100
+++ gcc/fortran/f95-lang.c	2005-11-07 10:30:35.000000000 +0100
@@ -120,6 +120,7 @@ static void gfc_expand_function (tree);
 #undef LANG_HOOKS_OMP_PREDETERMINED_SHARING
 #undef LANG_HOOKS_OMP_DISREGARD_VALUE_EXPR
 #undef LANG_HOOKS_OMP_PRIVATE_DEBUG_CLAUSE
+#undef LANG_HOOKS_OMP_FIRSTPRIVATIZE_TYPE_SIZES
 
 /* Define lang hooks.  */
 #define LANG_HOOKS_NAME                 "GNU F95"
@@ -142,6 +143,8 @@ static void gfc_expand_function (tree);
 #define LANG_HOOKS_OMP_PREDETERMINED_SHARING	gfc_omp_predetermined_sharing
 #define LANG_HOOKS_OMP_DISREGARD_VALUE_EXPR	gfc_omp_disregard_value_expr
 #define LANG_HOOKS_OMP_PRIVATE_DEBUG_CLAUSE	gfc_omp_private_debug_clause
+#define LANG_HOOKS_OMP_FIRSTPRIVATIZE_TYPE_SIZES \
+  gfc_omp_firstprivatize_type_sizes
 
 const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
 
--- gcc/fortran/trans.h.jj	2005-11-06 00:31:31.000000000 +0100
+++ gcc/fortran/trans.h	2005-11-07 10:31:26.000000000 +0100
@@ -447,6 +447,8 @@ bool gfc_omp_privatize_by_reference (tre
 enum omp_clause_default_kind gfc_omp_predetermined_sharing (tree);
 bool gfc_omp_disregard_value_expr (tree, bool);
 bool gfc_omp_private_debug_clause (tree, bool);
+struct gimplify_omp_ctx;
+void gfc_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *, tree);
 
 /* Runtime library function decls.  */
 extern GTY(()) tree gfor_fndecl_internal_malloc;

	Jakub


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