diff mbox

[gomp4] fiuxup openacc default handling

Message ID 55B5143E.4080303@acm.org
State New
Headers show

Commit Message

Nathan Sidwell July 26, 2015, 5:09 p.m. UTC
I've committed this update to my earlier breakout of default handling.  After 
complaining about something because of 'none', we should fall through to the 
default handling, to prevent ICEing later (on patch seriesI'm working on).  This 
matches the OMP default handling.  Also tweaked the setting of GOVD_ flags 
slightly, to make the firstprivate handling I'm working on less invasive.

nathan

Comments

Tom de Vries July 27, 2015, 3:21 p.m. UTC | #1
On 26/07/15 19:09, Nathan Sidwell wrote:
> I've committed this update to my earlier breakout of default handling.
> After complaining about something because of 'none', we should fall
> through to the default handling, to prevent ICEing later (on patch
> seriesI'm working on).  This matches the OMP default handling.  Also
> tweaked the setting of GOVD_ flags slightly, to make the firstprivate
> handling I'm working on less invasive.
>

Hi,

this causes PR 67027 - "[gomp4] FAIL: gfortran.dg/goacc/modules.f95 -O 
(internal compiler error)".

Thanks,
- Tom

> nathan
>
> gomp4-gimp-fix.patch
>
>
> 2015-07-26  Nathan Sidwell<nathan@codesourcery.com>
>
> 	* gimplify.c (oacc_default_clause): Fallthrough to unspecified
> 	handling.  Propagate mapping from outer scope.
>
> Index: gcc/gimplify.c
> ===================================================================
> --- gcc/gimplify.c	(revision 226226)
> +++ gcc/gimplify.c	(working copy)
> @@ -5930,7 +5930,7 @@ oacc_default_clause (struct gimplify_omp
>   	       DECL_NAME (lang_hooks.decls.omp_report_decl (decl)), rkind);
>   	error_at (ctx->location, "enclosing OpenACC %s construct", rkind);
>         }
> -    break;
> +      /* FALLTHRU.  */
>
>       case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
>         {
> @@ -5944,33 +5944,39 @@ oacc_default_clause (struct gimplify_omp
>   		  continue;
>   		if (!(octx->region_type & (ORT_TARGET_DATA | ORT_TARGET)))
>   		  break;
> -		if (splay_tree_lookup (octx->variables, (splay_tree_key) decl))
> +	      splay_tree_node n2
> +		= splay_tree_lookup (octx->variables, (splay_tree_key) decl);
> +	      if (n2)
> +		{
> +		  flags |= n2->value & GOVD_MAP;
>   		  goto found_outer;
> +		}
>   	      }
>   	  }
>
> -	{
> -	  tree type = TREE_TYPE (decl);
> -	  /*  Should this  be REFERENCE_TYPE_P? */
> -	  if (POINTER_TYPE_P (type))
> -	    type = TREE_TYPE (type);
> +	if (is_global_var (decl) && device_resident_p (decl))
> +	  flags |= GOVD_MAP_TO_ONLY | GOVD_MAP;
> +	/* Scalars under kernels are default 'copy'.  */
> +	else if (ctx->acc_region_kind == ARK_KERNELS)
> +	  flags |= GOVD_FORCE_MAP | GOVD_MAP;
> +	else if (ctx->acc_region_kind == ARK_PARALLEL)
> +	  {
> +	    tree type = TREE_TYPE (decl);
> +
> +	    /*  Should this  be REFERENCE_TYPE_P? */
> +	    if (POINTER_TYPE_P (type))
> +	      type = TREE_TYPE (type);
>   	
> -	  /* For OpenACC regions, array and aggregate variables
> -	     default to present_or_copy, while scalar variables
> -	     by default are firstprivate (gang-local) in parallel.  */
> -	  if (!AGGREGATE_TYPE_P (type))
> -	    {
> -	      if (is_global_var (decl) && device_resident_p (decl))
> -		flags |= GOVD_MAP_TO_ONLY;
> -	      else if (ctx->acc_region_kind == ARK_PARALLEL)
> -		flags |= (GOVD_GANGLOCAL | GOVD_MAP_TO_ONLY);
> -	      /* Scalars under kernels are default 'copy'.  */
> -	      else if (ctx->acc_region_kind == ARK_KERNELS)
> -		flags |= GOVD_FORCE_MAP;
> -	      else
> -		gcc_unreachable ();
> -	    }
> +	    if (AGGREGATE_TYPE_P (type))
> +	      /* Aggregates default to 'copy'.  This should really
> +		 include GOVD_FORCE_MAP.  */
> +	      flags |= GOVD_MAP;
> +	    else
> +	      /* Scalars default tp 'firstprivate'.  */
> +	      flags |= GOVD_GANGLOCAL | GOVD_MAP_TO_ONLY | GOVD_MAP;
>   	  }
> +	else
> +	  gcc_unreachable ();
>         found_outer:;
>         }
>         break;
> @@ -6020,7 +6026,8 @@ omp_notice_variable (struct gimplify_omp
>
>   	  if (is_oacc)
>   	    flags = oacc_default_clause (ctx, decl, in_code, flags);
> -	  flags |= GOVD_MAP;
> +	  else
> +	    flags |= GOVD_MAP;
>
>   	  if (!lang_hooks.types.omp_mappable_type (TREE_TYPE (decl), is_oacc))
>   	    {
>
Nathan Sidwell July 27, 2015, 3:27 p.m. UTC | #2
On 07/27/15 11:21, Tom de Vries wrote:
> On 26/07/15 19:09, Nathan Sidwell wrote:
>> I've committed this update to my earlier breakout of default handling.
>> After complaining about something because of 'none', we should fall
>> through to the default handling, to prevent ICEing later (on patch
>> seriesI'm working on).  This matches the OMP default handling.  Also
>> tweaked the setting of GOVD_ flags slightly, to make the firstprivate
>> handling I'm working on less invasive.
>>
>
> Hi,
>
> this causes PR 67027 - "[gomp4] FAIL: gfortran.dg/goacc/modules.f95 -O (internal
> compiler error)".

Will take a look ...
diff mbox

Patch

2015-07-26  Nathan Sidwell  <nathan@codesourcery.com>

	* gimplify.c (oacc_default_clause): Fallthrough to unspecified
	handling.  Propagate mapping from outer scope.

Index: gcc/gimplify.c
===================================================================
--- gcc/gimplify.c	(revision 226226)
+++ gcc/gimplify.c	(working copy)
@@ -5930,7 +5930,7 @@  oacc_default_clause (struct gimplify_omp
 	       DECL_NAME (lang_hooks.decls.omp_report_decl (decl)), rkind);
 	error_at (ctx->location, "enclosing OpenACC %s construct", rkind);
       }
-    break;
+      /* FALLTHRU.  */
 
     case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
       {
@@ -5944,33 +5944,39 @@  oacc_default_clause (struct gimplify_omp
 		  continue;
 		if (!(octx->region_type & (ORT_TARGET_DATA | ORT_TARGET)))
 		  break;
-		if (splay_tree_lookup (octx->variables, (splay_tree_key) decl))
+	      splay_tree_node n2
+		= splay_tree_lookup (octx->variables, (splay_tree_key) decl);
+	      if (n2)
+		{
+		  flags |= n2->value & GOVD_MAP;
 		  goto found_outer;
+		}
 	      }
 	  }
 
-	{
-	  tree type = TREE_TYPE (decl);
-	  /*  Should this  be REFERENCE_TYPE_P? */
-	  if (POINTER_TYPE_P (type))
-	    type = TREE_TYPE (type);
+	if (is_global_var (decl) && device_resident_p (decl))
+	  flags |= GOVD_MAP_TO_ONLY | GOVD_MAP;
+	/* Scalars under kernels are default 'copy'.  */
+	else if (ctx->acc_region_kind == ARK_KERNELS)
+	  flags |= GOVD_FORCE_MAP | GOVD_MAP;
+	else if (ctx->acc_region_kind == ARK_PARALLEL)
+	  {
+	    tree type = TREE_TYPE (decl);
+
+	    /*  Should this  be REFERENCE_TYPE_P? */
+	    if (POINTER_TYPE_P (type))
+	      type = TREE_TYPE (type);
 	
-	  /* For OpenACC regions, array and aggregate variables
-	     default to present_or_copy, while scalar variables
-	     by default are firstprivate (gang-local) in parallel.  */
-	  if (!AGGREGATE_TYPE_P (type))
-	    {
-	      if (is_global_var (decl) && device_resident_p (decl))
-		flags |= GOVD_MAP_TO_ONLY;
-	      else if (ctx->acc_region_kind == ARK_PARALLEL)
-		flags |= (GOVD_GANGLOCAL | GOVD_MAP_TO_ONLY);
-	      /* Scalars under kernels are default 'copy'.  */
-	      else if (ctx->acc_region_kind == ARK_KERNELS)
-		flags |= GOVD_FORCE_MAP;
-	      else
-		gcc_unreachable ();
-	    }
+	    if (AGGREGATE_TYPE_P (type))
+	      /* Aggregates default to 'copy'.  This should really
+		 include GOVD_FORCE_MAP.  */
+	      flags |= GOVD_MAP;
+	    else
+	      /* Scalars default tp 'firstprivate'.  */
+	      flags |= GOVD_GANGLOCAL | GOVD_MAP_TO_ONLY | GOVD_MAP;
 	  }
+	else
+	  gcc_unreachable ();
       found_outer:;
       }
       break;
@@ -6020,7 +6026,8 @@  omp_notice_variable (struct gimplify_omp
 
 	  if (is_oacc)
 	    flags = oacc_default_clause (ctx, decl, in_code, flags);
-	  flags |= GOVD_MAP;
+	  else
+	    flags |= GOVD_MAP;
 
 	  if (!lang_hooks.types.omp_mappable_type (TREE_TYPE (decl), is_oacc))
 	    {