diff mbox

[gomp4] Add new oacc_transform patch

Message ID 55AE7E19.90508@codesourcery.com
State New
Headers show

Commit Message

Cesar Philippidis July 21, 2015, 5:15 p.m. UTC
Jakub,

Nathan pointed out that I should make the fold_oacc_reductions pass that
I introduced in my reduction patch more generic so that other openacc
transformations may use it. This patch introduces an empty skeleton pass
called oacc_transform. Currently I'm stashing it inside omp-low.c. Is
that a good place for it, or should I move it to it's own separate file?

The motivation behind this pass is to allow us to generate
target-specific code in a generic manner. E.g., for reductions, I'm
emitting calls to internal functions during lowering, then later on in
this pass I'm expanding those calls using target machine hooks. This
pass will run after lto on the target compiler.

Thanks,
Cesar

Comments

Thomas Schwinge July 28, 2015, 9:21 a.m. UTC | #1
Hi!

On Tue, 21 Jul 2015 10:15:05 -0700, Cesar Philippidis <cesar@codesourcery.com> wrote:
> Jakub,
> 
> Nathan pointed out that I should make the fold_oacc_reductions pass that
> I introduced in my reduction patch more generic so that other openacc
> transformations may use it. This patch introduces an empty skeleton pass
> called oacc_transform. Currently I'm stashing it inside omp-low.c. Is
> that a good place for it, or should I move it to it's own separate file?
> 
> The motivation behind this pass is to allow us to generate
> target-specific code in a generic manner. E.g., for reductions, I'm
> emitting calls to internal functions during lowering, then later on in
> this pass I'm expanding those calls using target machine hooks. This
> pass will run after lto on the target compiler.

(Another use case for this is to evaluate acc_on_device with compile-time
constant argument earlier than currently.)

Jakub, is this conceptually OK, or even OK to commit to trunk already?


Cesar, please address the following compiler diagnostig:

> 2015-07-21  Cesar Philippidis  <cesar@codesourcery.com>
> 
> 	gcc/
> 	* omp-low.c (execute_oacc_transform): New function.
> 	(class pass_oacc_transform): New function.
> 	(make_pass_oacc_transform): New function.
> 	* passes.def: Add pass_oacc_transform to all_passes.
> 	* tree-pass.h (make_pass_oacc_transform): Declare.
> 	
> 
> diff --git a/gcc/omp-low.c b/gcc/omp-low.c
> index 388013c..23989f9 100644
> --- a/gcc/omp-low.c
> +++ b/gcc/omp-low.c
> @@ -14394,4 +14394,76 @@ make_pass_late_lower_omp (gcc::context *ctxt)
>    return new pass_late_lower_omp (ctxt);
>  }
>  
> +/* Main entry point for oacc transformations which run on the device
> +   compiler.  */
> +
> +static unsigned int
> +execute_oacc_transform ()
> +{
> +  basic_block bb;
> +  gimple_stmt_iterator gsi;
> +  gimple stmt;
> +
> +  if (!lookup_attribute ("oacc function",
> +			 DECL_ATTRIBUTES (current_function_decl)))
> +    return 0;
> +
> +
> +  FOR_ALL_BB_FN (bb, cfun)
> +    {
> +      gsi = gsi_start_bb (bb);
> +
> +      while (!gsi_end_p (gsi))
> +	{
> +	  stmt = gsi_stmt (gsi);
> +	  gsi_next (&gsi);
> +	}
> +    }
> +
> +  return 0;
> +}

    [...]/source-gcc/gcc/omp-low.c: In function 'unsigned int execute_oacc_transform()':
    [...]/source-gcc/gcc/omp-low.c:14406:10: error: variable 'stmt' set but not used [-Werror=unused-but-set-variable]
       gimple stmt;
              ^

> +
> +namespace {
> +
> +const pass_data pass_data_oacc_transform =
> +{
> +  GIMPLE_PASS, /* type */
> +  "fold_oacc_transform", /* name */
> +  OPTGROUP_NONE, /* optinfo_flags */
> +  TV_NONE, /* tv_id */
> +  PROP_cfg, /* properties_required */
> +  0 /* Possibly PROP_gimple_eomp.  */, /* properties_provided */
> +  0, /* properties_destroyed */
> +  0, /* todo_flags_start */
> +  TODO_update_ssa, /* todo_flags_finish */
> +};
> +
> +class pass_oacc_transform : public gimple_opt_pass
> +{
> +public:
> +  pass_oacc_transform (gcc::context *ctxt)
> +    : gimple_opt_pass (pass_data_oacc_transform, ctxt)
> +  {}
> +
> +  /* opt_pass methods: */
> +  virtual unsigned int execute (function *)
> +    {
> +      bool gate = (flag_openacc != 0 && !seen_error ());
> +
> +      if (!gate)
> +	return 0;
> +
> +      return execute_oacc_transform ();
> +    }
> +
> +}; // class pass_oacc_transform
> +
> +} // anon namespace
> +
> +gimple_opt_pass *
> +make_pass_oacc_transform (gcc::context *ctxt)
> +{
> +  return new pass_oacc_transform (ctxt);
> +}
> +
>  #include "gt-omp-low.h"
> diff --git a/gcc/passes.def b/gcc/passes.def
> index 43e67df..6a2b095 100644
> --- a/gcc/passes.def
> +++ b/gcc/passes.def
> @@ -165,6 +165,7 @@ along with GCC; see the file COPYING3.  If not see
>    INSERT_PASSES_AFTER (all_passes)
>    NEXT_PASS (pass_fixup_cfg);
>    NEXT_PASS (pass_lower_eh_dispatch);
> +  NEXT_PASS (pass_oacc_transform);
>    NEXT_PASS (pass_all_optimizations);
>    PUSH_INSERT_PASSES_WITHIN (pass_all_optimizations)
>        NEXT_PASS (pass_remove_cgraph_callee_edges);
> diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h
> index 13f20ea..67dc017 100644
> --- a/gcc/tree-pass.h
> +++ b/gcc/tree-pass.h
> @@ -410,6 +410,7 @@ extern gimple_opt_pass *make_pass_late_lower_omp (gcc::context *ctxt);
>  extern gimple_opt_pass *make_pass_diagnose_omp_blocks (gcc::context *ctxt);
>  extern gimple_opt_pass *make_pass_expand_omp (gcc::context *ctxt);
>  extern gimple_opt_pass *make_pass_expand_omp_ssa (gcc::context *ctxt);
> +extern gimple_opt_pass *make_pass_oacc_transform (gcc::context *ctxt);
>  extern gimple_opt_pass *make_pass_object_sizes (gcc::context *ctxt);
>  extern gimple_opt_pass *make_pass_strlen (gcc::context *ctxt);
>  extern gimple_opt_pass *make_pass_fold_builtins (gcc::context *ctxt);


Grüße,
 Thomas
diff mbox

Patch

2015-07-21  Cesar Philippidis  <cesar@codesourcery.com>

	gcc/
	* omp-low.c (execute_oacc_transform): New function.
	(class pass_oacc_transform): New function.
	(make_pass_oacc_transform): New function.
	* passes.def: Add pass_oacc_transform to all_passes.
	* tree-pass.h (make_pass_oacc_transform): Declare.
	

diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 388013c..23989f9 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -14394,4 +14394,76 @@  make_pass_late_lower_omp (gcc::context *ctxt)
   return new pass_late_lower_omp (ctxt);
 }
 
+/* Main entry point for oacc transformations which run on the device
+   compiler.  */
+
+static unsigned int
+execute_oacc_transform ()
+{
+  basic_block bb;
+  gimple_stmt_iterator gsi;
+  gimple stmt;
+
+  if (!lookup_attribute ("oacc function",
+			 DECL_ATTRIBUTES (current_function_decl)))
+    return 0;
+
+
+  FOR_ALL_BB_FN (bb, cfun)
+    {
+      gsi = gsi_start_bb (bb);
+
+      while (!gsi_end_p (gsi))
+	{
+	  stmt = gsi_stmt (gsi);
+	  gsi_next (&gsi);
+	}
+    }
+
+  return 0;
+}
+
+namespace {
+
+const pass_data pass_data_oacc_transform =
+{
+  GIMPLE_PASS, /* type */
+  "fold_oacc_transform", /* name */
+  OPTGROUP_NONE, /* optinfo_flags */
+  TV_NONE, /* tv_id */
+  PROP_cfg, /* properties_required */
+  0 /* Possibly PROP_gimple_eomp.  */, /* properties_provided */
+  0, /* properties_destroyed */
+  0, /* todo_flags_start */
+  TODO_update_ssa, /* todo_flags_finish */
+};
+
+class pass_oacc_transform : public gimple_opt_pass
+{
+public:
+  pass_oacc_transform (gcc::context *ctxt)
+    : gimple_opt_pass (pass_data_oacc_transform, ctxt)
+  {}
+
+  /* opt_pass methods: */
+  virtual unsigned int execute (function *)
+    {
+      bool gate = (flag_openacc != 0 && !seen_error ());
+
+      if (!gate)
+	return 0;
+
+      return execute_oacc_transform ();
+    }
+
+}; // class pass_oacc_transform
+
+} // anon namespace
+
+gimple_opt_pass *
+make_pass_oacc_transform (gcc::context *ctxt)
+{
+  return new pass_oacc_transform (ctxt);
+}
+
 #include "gt-omp-low.h"
diff --git a/gcc/passes.def b/gcc/passes.def
index 43e67df..6a2b095 100644
--- a/gcc/passes.def
+++ b/gcc/passes.def
@@ -165,6 +165,7 @@  along with GCC; see the file COPYING3.  If not see
   INSERT_PASSES_AFTER (all_passes)
   NEXT_PASS (pass_fixup_cfg);
   NEXT_PASS (pass_lower_eh_dispatch);
+  NEXT_PASS (pass_oacc_transform);
   NEXT_PASS (pass_all_optimizations);
   PUSH_INSERT_PASSES_WITHIN (pass_all_optimizations)
       NEXT_PASS (pass_remove_cgraph_callee_edges);
diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h
index 13f20ea..67dc017 100644
--- a/gcc/tree-pass.h
+++ b/gcc/tree-pass.h
@@ -410,6 +410,7 @@  extern gimple_opt_pass *make_pass_late_lower_omp (gcc::context *ctxt);
 extern gimple_opt_pass *make_pass_diagnose_omp_blocks (gcc::context *ctxt);
 extern gimple_opt_pass *make_pass_expand_omp (gcc::context *ctxt);
 extern gimple_opt_pass *make_pass_expand_omp_ssa (gcc::context *ctxt);
+extern gimple_opt_pass *make_pass_oacc_transform (gcc::context *ctxt);
 extern gimple_opt_pass *make_pass_object_sizes (gcc::context *ctxt);
 extern gimple_opt_pass *make_pass_strlen (gcc::context *ctxt);
 extern gimple_opt_pass *make_pass_fold_builtins (gcc::context *ctxt);