diff mbox

[gomp4] Accelerator constructs omp lowering and expansion

Message ID 877g7zfrzg.fsf@kepler.schwinge.homeip.net
State New
Headers show

Commit Message

Thomas Schwinge March 12, 2014, 1:48 p.m. UTC
Hi!

On Wed, 4 Sep 2013 20:54:47 +0200, Jakub Jelinek <jakub@redhat.com> wrote:
> This patch implements #pragma omp {target{, data, update},teams} lowering
> and expansion, and adds stub calls into libgomp, so that (for now
> unconditionally) we can at least always fall back to host execution.

> 2013-09-04  Jakub Jelinek  <jakub@redhat.com>

> 	* omp-low.c [...]
> 	(create_omp_child_function): If current function has
> 	"omp declare target" attribute or if current region
> 	is OMP_TARGET or lexically nested in it, add that
> 	attribute to the omp child function.

It seems that I have missed this one when generalizing the existing code
for OpenACC:

> --- gcc/omp-low.c.jj	2013-08-27 22:44:31.000000000 +0200
> +++ gcc/omp-low.c	2013-09-04 19:58:30.320019227 +0200
> @@ -1677,6 +1775,26 @@ create_omp_child_function (omp_context *
>    DECL_EXTERNAL (decl) = 0;
>    DECL_CONTEXT (decl) = NULL_TREE;
>    DECL_INITIAL (decl) = make_node (BLOCK);
> +  bool target_p = false;
> +  if (lookup_attribute ("omp declare target",
> +			DECL_ATTRIBUTES (current_function_decl)))
> +    target_p = true;
> +  else
> +    {
> +      omp_context *octx;
> +      for (octx = ctx; octx; octx = octx->outer)
> +	if (gimple_code (octx->stmt) == GIMPLE_OMP_TARGET
> +	    && gimple_omp_target_kind (octx->stmt)
> +	       == GF_OMP_TARGET_KIND_REGION)
> +	  {
> +	    target_p = true;
> +	    break;
> +	  }
> +    }
> +  if (target_p)
> +    DECL_ATTRIBUTES (decl)
> +      = tree_cons (get_identifier ("omp declare target"),
> +		   NULL_TREE, DECL_ATTRIBUTES (decl));
>  
>    t = build_decl (DECL_SOURCE_LOCATION (decl),
>  		  RESULT_DECL, NULL_TREE, void_type_node);

Even if not yet relevant at the moment for OpenACC, I think it makes
sense to make it more obvious, and change the code as follows.  Will
commit soon unless someone disagrees.

commit a07a6e3414da55ff4bbc8b7f0ceb747c1712fecc
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Wed Mar 12 12:30:58 2014 +0100

    	* gcc/omp-low.c (create_omp_child_function): Use is_gimple_omp_offloaded.



Grüße,
 Thomas
diff mbox

Patch

diff --git gcc/omp-low.c gcc/omp-low.c
index 32f702c..82c0489 100644
--- gcc/omp-low.c
+++ gcc/omp-low.c
@@ -1979,16 +1979,12 @@  create_omp_child_function (omp_context *ctx, bool task_copy)
     {
       omp_context *octx;
       for (octx = ctx; octx; octx = octx->outer)
-	if (gimple_code (octx->stmt) == GIMPLE_OMP_TARGET
-	    && gimple_omp_target_kind (octx->stmt)
-	       == GF_OMP_TARGET_KIND_REGION)
+	if (is_gimple_omp_offloaded (octx->stmt))
 	  {
 	    target_p = true;
 	    break;
 	  }
     }
-  gcc_assert (!is_gimple_omp_oacc_specifically (ctx->stmt)
-	      || !target_p);
   if (target_p)
     DECL_ATTRIBUTES (decl)
       = tree_cons (get_identifier ("omp declare target"),