public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Julian Brown <julian@codesourcery.com>
Cc: James Norris <jnorris@codesourcery.com>,
	       GCC Patches <gcc-patches@gcc.gnu.org>,
	       "Joseph S. Myers" <joseph@codesourcery.com>,
	       Nathan Sidwell <Nathan_Sidwell@mentor.com>
Subject: Re: [OpenACC 0/7] host_data construct
Date: Thu, 19 Nov 2015 13:13:00 -0000	[thread overview]
Message-ID: <20151119131345.GX5675@tucnak.redhat.com> (raw)
In-Reply-To: <20151118124747.30a2ec5d@octopus>

On Wed, Nov 18, 2015 at 12:47:47PM +0000, Julian Brown wrote:

The FE/gimplifier part is okay, but I really don't like the
omp-low.c changes, mostly the *lookup_decl_in_outer_ctx* changes.
If I count well, we have right now 27 maybe_lookup_decl_in_outer_ctx
callers and 7 lookup_decl_in_outer_ctx callers, you want to change
behavior of 1 maybe_lookup_decl_in_outer_ctx and 1
lookup_decl_in_outer_ctx.  Why exactly those 2 and not the others?
What are the exact rules (what does the standard say about it)?
I'd expect that all phases (scan_sharing_clauses, lower_omp* and
expand_omp*) should agree on the same behavior, otherwise I can't see how it
can work properly.  And, if you want to change just a couple of spots,
I'd strongly prefer to add new functions with this weirdo behavior, rather
than tweaking the original function.

> --- a/gcc/omp-low.c
> +++ b/gcc/omp-low.c
> @@ -390,8 +390,8 @@ scan_omp_op (tree *tp, omp_context *ctx)
>  }
>  
>  static void lower_omp (gimple_seq *, omp_context *);
> -static tree lookup_decl_in_outer_ctx (tree, omp_context *);
> -static tree maybe_lookup_decl_in_outer_ctx (tree, omp_context *);
> +static tree lookup_decl_in_outer_ctx (tree, omp_context *, bool = false);
> +static tree maybe_lookup_decl_in_outer_ctx (tree, omp_context *, bool = false);
>  
>  /* Find an OMP clause of type KIND within CLAUSES.  */
>  
> @@ -1935,6 +1935,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
>  	  install_var_local (decl, ctx);
>  	  break;
>  
> +	case OMP_CLAUSE_USE_DEVICE:
>  	case OMP_CLAUSE_USE_DEVICE_PTR:
>  	  decl = OMP_CLAUSE_DECL (c);
>  	  if (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
> @@ -2137,7 +2138,6 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
>  	  break;
>  
>  	case OMP_CLAUSE_DEVICE_RESIDENT:
> -	case OMP_CLAUSE_USE_DEVICE:
>  	case OMP_CLAUSE__CACHE_:
>  	  sorry ("Clause not supported yet");
>  	  break;
> @@ -2288,6 +2288,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
>  	case OMP_CLAUSE_SIMD:
>  	case OMP_CLAUSE_NOGROUP:
>  	case OMP_CLAUSE_DEFAULTMAP:
> +	case OMP_CLAUSE_USE_DEVICE:
>  	case OMP_CLAUSE_USE_DEVICE_PTR:
>  	case OMP_CLAUSE__CILK_FOR_COUNT_:
>  	case OMP_CLAUSE_ASYNC:
> @@ -2305,7 +2306,6 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
>  	  break;
>  
>  	case OMP_CLAUSE_DEVICE_RESIDENT:
> -	case OMP_CLAUSE_USE_DEVICE:
>  	case OMP_CLAUSE__CACHE_:
>  	  sorry ("Clause not supported yet");
>  	  break;
> @@ -3608,6 +3608,8 @@ check_omp_nesting_restrictions (gimple *stmt, omp_context *ctx)
>  	    case GF_OMP_TARGET_KIND_OACC_UPDATE: stmt_name = "update"; break;
>  	    case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA:
>  	      stmt_name = "enter/exit data"; break;
> +	    case GF_OMP_TARGET_KIND_OACC_HOST_DATA: stmt_name = "host_data";
> +	      break;
>  	    default: gcc_unreachable ();
>  	    }
>  	  switch (gimple_omp_target_kind (ctx->stmt))
> @@ -3619,6 +3621,8 @@ check_omp_nesting_restrictions (gimple *stmt, omp_context *ctx)
>  	    case GF_OMP_TARGET_KIND_OACC_KERNELS:
>  	      ctx_stmt_name = "kernels"; break;
>  	    case GF_OMP_TARGET_KIND_OACC_DATA: ctx_stmt_name = "data"; break;
> +	    case GF_OMP_TARGET_KIND_OACC_HOST_DATA:
> +	      ctx_stmt_name = "host_data"; break;
>  	    default: gcc_unreachable ();
>  	    }
>  
> @@ -3941,13 +3945,22 @@ maybe_lookup_ctx (gimple *stmt)
>      parallelism happens only rarely.  */
>  
>  static tree
> -lookup_decl_in_outer_ctx (tree decl, omp_context *ctx)
> +lookup_decl_in_outer_ctx (tree decl, omp_context *ctx,
> +			  bool skip_hostdata)
>  {
>    tree t;
>    omp_context *up;
>  
>    for (up = ctx->outer, t = NULL; up && t == NULL; up = up->outer)
> -    t = maybe_lookup_decl (decl, up);
> +    {
> +      if (skip_hostdata
> +	  && gimple_code (up->stmt) == GIMPLE_OMP_TARGET
> +	  && gimple_omp_target_kind (up->stmt)
> +	     == GF_OMP_TARGET_KIND_OACC_HOST_DATA)
> +	continue;
> +
> +      t = maybe_lookup_decl (decl, up);
> +    }
>  
>    gcc_assert (!ctx->is_nested || t || is_global_var (decl));
>  
> @@ -3959,13 +3972,22 @@ lookup_decl_in_outer_ctx (tree decl, omp_context *ctx)
>     in outer contexts.  */
>  
>  static tree
> -maybe_lookup_decl_in_outer_ctx (tree decl, omp_context *ctx)
> +maybe_lookup_decl_in_outer_ctx (tree decl, omp_context *ctx,
> +				bool skip_hostdata)
>  {
>    tree t = NULL;
>    omp_context *up;
>  
>    for (up = ctx->outer, t = NULL; up && t == NULL; up = up->outer)
> -    t = maybe_lookup_decl (decl, up);
> +    {
> +      if (skip_hostdata
> +	  && gimple_code (up->stmt) == GIMPLE_OMP_TARGET
> +	  && gimple_omp_target_kind (up->stmt)
> +	     == GF_OMP_TARGET_KIND_OACC_HOST_DATA)
> +	continue;
> +
> +      t = maybe_lookup_decl (decl, up);
> +    }
>  
>    return t ? t : decl;
>  }
> @@ -12499,6 +12521,7 @@ expand_omp_target (struct omp_region *region)
>        break;
>      case GF_OMP_TARGET_KIND_DATA:
>      case GF_OMP_TARGET_KIND_OACC_DATA:
> +    case GF_OMP_TARGET_KIND_OACC_HOST_DATA:
>        data_region = true;
>        break;
>      default:
> @@ -12742,6 +12765,9 @@ expand_omp_target (struct omp_region *region)
>      case GF_OMP_TARGET_KIND_OACC_DECLARE:
>        start_ix = BUILT_IN_GOACC_DECLARE;
>        break;
> +    case GF_OMP_TARGET_KIND_OACC_HOST_DATA:
> +      start_ix = BUILT_IN_GOACC_HOST_DATA;
> +      break;
>      default:
>        gcc_unreachable ();
>      }
> @@ -12866,6 +12892,7 @@ expand_omp_target (struct omp_region *region)
>      case BUILT_IN_GOACC_DATA_START:
>      case BUILT_IN_GOACC_DECLARE:
>      case BUILT_IN_GOMP_TARGET_DATA:
> +    case BUILT_IN_GOACC_HOST_DATA:
>        break;
>      case BUILT_IN_GOMP_TARGET:
>      case BUILT_IN_GOMP_TARGET_UPDATE:
> @@ -13173,6 +13200,7 @@ build_omp_regions_1 (basic_block bb, struct omp_region *parent,
>  		case GF_OMP_TARGET_KIND_OACC_PARALLEL:
>  		case GF_OMP_TARGET_KIND_OACC_KERNELS:
>  		case GF_OMP_TARGET_KIND_OACC_DATA:
> +		case GF_OMP_TARGET_KIND_OACC_HOST_DATA:
>  		  break;
>  		case GF_OMP_TARGET_KIND_UPDATE:
>  		case GF_OMP_TARGET_KIND_ENTER_DATA:
> @@ -14972,6 +15000,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
>        break;
>      case GF_OMP_TARGET_KIND_DATA:
>      case GF_OMP_TARGET_KIND_OACC_DATA:
> +    case GF_OMP_TARGET_KIND_OACC_HOST_DATA:
>        data_region = true;
>        break;
>      default:
> @@ -15079,7 +15108,8 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
>  	  {
>  	    if (TREE_CODE (TREE_TYPE (var)) == ARRAY_TYPE)
>  	      {
> -		if (is_global_var (maybe_lookup_decl_in_outer_ctx (var, ctx))
> +		if (is_global_var (maybe_lookup_decl_in_outer_ctx (var, ctx,
> +								   true))
>  		    && varpool_node::get_create (var)->offloadable)
>  		  continue;
>  
> @@ -15178,6 +15208,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
>  	  }
>  	break;
>  
> +      case OMP_CLAUSE_USE_DEVICE:
>        case OMP_CLAUSE_USE_DEVICE_PTR:
>        case OMP_CLAUSE_IS_DEVICE_PTR:
>  	var = OMP_CLAUSE_DECL (c);
> @@ -15316,7 +15347,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
>  	      talign = DECL_ALIGN_UNIT (ovar);
>  	    if (nc)
>  	      {
> -		var = lookup_decl_in_outer_ctx (ovar, ctx);
> +		var = lookup_decl_in_outer_ctx (ovar, ctx, true);
>  		x = build_sender_ref (ovar, ctx);
>  
>  		if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
> @@ -15563,12 +15594,14 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
>  				    build_int_cstu (tkind_type, tkind));
>  	    break;
>  
> +	  case OMP_CLAUSE_USE_DEVICE:
>  	  case OMP_CLAUSE_USE_DEVICE_PTR:
>  	  case OMP_CLAUSE_IS_DEVICE_PTR:
>  	    ovar = OMP_CLAUSE_DECL (c);
>  	    var = lookup_decl_in_outer_ctx (ovar, ctx);
>  	    x = build_sender_ref (ovar, ctx);
> -	    if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_PTR)
> +	    if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_PTR
> +		|| OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE)
>  	      tkind = GOMP_MAP_USE_DEVICE_PTR;
>  	    else
>  	      tkind = GOMP_MAP_FIRSTPRIVATE_INT;
> @@ -15771,10 +15804,12 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
>  				     gimple_build_assign (new_var, x));
>  	      }
>  	    break;
> +	  case OMP_CLAUSE_USE_DEVICE:
>  	  case OMP_CLAUSE_USE_DEVICE_PTR:
>  	  case OMP_CLAUSE_IS_DEVICE_PTR:
>  	    var = OMP_CLAUSE_DECL (c);
> -	    if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_PTR)
> +	    if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_PTR
> +		|| OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE)
>  	      x = build_sender_ref (var, ctx);
>  	    else
>  	      x = build_receiver_ref (var, false, ctx);
> @@ -16761,6 +16796,7 @@ make_gimple_omp_edges (basic_block bb, struct omp_region **region,
>  	case GF_OMP_TARGET_KIND_OACC_PARALLEL:
>  	case GF_OMP_TARGET_KIND_OACC_KERNELS:
>  	case GF_OMP_TARGET_KIND_OACC_DATA:
> +	case GF_OMP_TARGET_KIND_OACC_HOST_DATA:
>  	  break;
>  	case GF_OMP_TARGET_KIND_UPDATE:
>  	case GF_OMP_TARGET_KIND_ENTER_DATA:

	Jakub

  reply	other threads:[~2015-11-19 13:13 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-22 19:14 James Norris
2015-10-22 19:15 ` [OpenACC 1/7] host_data construct (C/C++ common) James Norris
2015-10-22 19:15 ` [OpenACC 2/7] host_data construct (C FE) James Norris
2015-10-22 19:16 ` [OpenACC 3/7] host_data construct (C front-end) James Norris
2015-10-22 19:18 ` [OpenACC 4/7] host_data construct (middle end) James Norris
2015-10-22 19:19 ` [OpenACC 5/7] host_data construct (gcc tests) James Norris
2015-10-22 19:20 ` [OpenACC 6/7] host_data construct James Norris
2015-10-22 19:22 ` [OpenACC 7/7] host_data construct (runtime tests) James Norris
2015-10-22 20:42 ` [OpenACC 0/7] host_data construct Joseph Myers
2015-10-22 20:53   ` James Norris
2015-10-23 16:01 ` [Bulk] " James Norris
2015-10-26 18:36   ` Jakub Jelinek
2015-10-27 15:57     ` Cesar Philippidis
2015-11-02 18:33     ` Julian Brown
2015-11-02 19:29       ` Jakub Jelinek
2015-11-12 11:16       ` Julian Brown
2015-11-18 12:48         ` Julian Brown
2015-11-19 13:13           ` Jakub Jelinek [this message]
2015-11-19 14:29             ` Julian Brown
2015-11-19 15:57               ` Jakub Jelinek
2015-11-30 19:34                 ` Julian Brown
2015-12-01  8:30                   ` Jakub Jelinek
2015-12-02 15:27                   ` Tom de Vries
2015-12-02 15:59                   ` Thomas Schwinge
2015-12-02 19:16                     ` Cesar Philippidis
2015-12-02 19:28                       ` Steve Kargl
2015-12-02 19:35                       ` Jakub Jelinek
2015-12-02 19:54                         ` Cesar Philippidis
2015-12-02 22:14                     ` [gomp4] " Thomas Schwinge
2016-04-08 13:41                       ` Fortran OpenACC host_data construct ICE (was: [gomp4] Re: [OpenACC 0/7] host_data construct) Thomas Schwinge
2016-02-02 13:57                     ` [OpenACC 0/7] host_data construct Thomas Schwinge
2015-11-13 15:31       ` [Bulk] " Jakub Jelinek
2015-12-23 11:02     ` Thomas Schwinge

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151119131345.GX5675@tucnak.redhat.com \
    --to=jakub@redhat.com \
    --cc=Nathan_Sidwell@mentor.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jnorris@codesourcery.com \
    --cc=joseph@codesourcery.com \
    --cc=julian@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).