public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [gomp4] Add new oacc_transform patch
@ 2015-07-21 17:27 Cesar Philippidis
  2015-07-28  9:36 ` Thomas Schwinge
  0 siblings, 1 reply; 3+ messages in thread
From: Cesar Philippidis @ 2015-07-21 17:27 UTC (permalink / raw)
  To: gcc-patches, Jakub Jelinek; +Cc: Nathan Sidwell

[-- Attachment #1: Type: text/plain, Size: 698 bytes --]

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

[-- Attachment #2: oacc-transform.diff --]
[-- Type: text/x-patch, Size: 3221 bytes --]

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);

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [gomp4] Add new oacc_transform patch
  2015-07-21 17:27 [gomp4] Add new oacc_transform patch Cesar Philippidis
@ 2015-07-28  9:36 ` Thomas Schwinge
  2015-07-28 15:44   ` Cesar Philippidis
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Schwinge @ 2015-07-28  9:36 UTC (permalink / raw)
  To: Cesar Philippidis, gcc-patches, Jakub Jelinek; +Cc: Nathan Sidwell

[-- Attachment #1: Type: text/plain, Size: 4916 bytes --]

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [gomp4] Add new oacc_transform patch
  2015-07-28  9:36 ` Thomas Schwinge
@ 2015-07-28 15:44   ` Cesar Philippidis
  0 siblings, 0 replies; 3+ messages in thread
From: Cesar Philippidis @ 2015-07-28 15:44 UTC (permalink / raw)
  To: Thomas Schwinge, gcc-patches, Jakub Jelinek; +Cc: Nathan Sidwell

[-- Attachment #1: Type: text/plain, Size: 1704 bytes --]

On 07/28/2015 02:21 AM, Thomas Schwinge wrote:

> 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;
>               ^

I could apply the attached patch, but I figured that you'd need the stmt
iterator for acc_on_device anyway. Should I apply the patch to
gomp-4_0-branch?

Cesar


[-- Attachment #2: oacc-xform.diff --]
[-- Type: text/x-patch, Size: 595 bytes --]

diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 479b28a..e237c75 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -14431,26 +14431,10 @@ make_pass_late_lower_omp (gcc::context *ctxt)
 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;
 }
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-07-28 15:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-21 17:27 [gomp4] Add new oacc_transform patch Cesar Philippidis
2015-07-28  9:36 ` Thomas Schwinge
2015-07-28 15:44   ` Cesar Philippidis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).