public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: James Norris <jnorris@codesourcery.com>
Cc: Thomas Schwinge <thomas@codesourcery.com>,
	       "Joseph S. Myers" <joseph@codesourcery.com>,
	       GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [OpenACC] declare directive
Date: Mon, 09 Nov 2015 16:21:00 -0000	[thread overview]
Message-ID: <20151109162117.GU5675@tucnak.redhat.com> (raw)
In-Reply-To: <5640C35C.9030907@codesourcery.com>

On Mon, Nov 09, 2015 at 10:01:32AM -0600, James Norris wrote:
> +      if (lookup_attribute ("omp declare target", DECL_ATTRIBUTES (decl)))

Here you only look up "omp declare target", not "omp declare target link".
So, what happens if you mix that (once in some copy clause, once in link),
or mention twice in link, etc.?  Needs testsuite coverage and clear rules.

> +	  DECL_ATTRIBUTES (decl) =
> +			tree_cons (id, NULL_TREE, DECL_ATTRIBUTES (decl));

Incorrect formatting, = goes already on the following line, no whitespace
at end of line, and next line is indented below CL from DECL.

> +	  t = build_omp_clause (OMP_CLAUSE_LOCATION (c) , OMP_CLAUSE_MAP);

Wrong formatting, no space before ,.

> +    if (ret_clauses)
> +      {
> +	tree fndecl = current_function_decl;
> +	tree attrs = lookup_attribute ("oacc declare returns",
> +				       DECL_ATTRIBUTES (fndecl));

Why do you use an attribute for this?  I think adding the automatic
vars to hash_map during gimplification of the OACC_DECLARE is best.

> +	    tree id = get_identifier ("oacc declare returns");
> +	    DECL_ATTRIBUTES (fndecl) =
> +			tree_cons (id, ret_clauses, DECL_ATTRIBUTES (fndecl));

Formatting error.

> --- a/gcc/gimplify.c
> +++ b/gcc/gimplify.c
> @@ -1065,6 +1065,7 @@ gimplify_bind_expr (tree *expr_p, gimple_seq *pre_p)
>    gimple_seq body, cleanup;
>    gcall *stack_save;
>    location_t start_locus = 0, end_locus = 0;
> +  tree ret_clauses = NULL;
>  
>    tree temp = voidify_wrapper_expr (bind_expr, NULL);
>  
> @@ -1166,9 +1167,56 @@ gimplify_bind_expr (tree *expr_p, gimple_seq *pre_p)
>  	  clobber_stmt = gimple_build_assign (t, clobber);
>  	  gimple_set_location (clobber_stmt, end_locus);
>  	  gimplify_seq_add_stmt (&cleanup, clobber_stmt);
> +
> +	  if (flag_openacc)
> +	    {
> +	      tree attrs = lookup_attribute ("oacc declare returns",
> +				       DECL_ATTRIBUTES (current_function_decl));
> +	      tree clauses, c, c_next = NULL, c_prev = NULL;
> +
> +	      if (!attrs)
> +		break;
> +
> +	      clauses = TREE_VALUE (attrs);
> +
> +	      for (c = clauses; c; c_prev = c, c = c_next)
> +		{
> +		  c_next = OMP_CLAUSE_CHAIN (c);
> +
> +		  if (t == OMP_CLAUSE_DECL (c))
> +		    {
> +		      if (ret_clauses)
> +			OMP_CLAUSE_CHAIN (c) = ret_clauses;
> +
> +		      ret_clauses = c;
> +
> +		      if (c_prev == NULL)
> +			clauses = c_next;
> +		      else
> +			OMP_CLAUSE_CHAIN (c_prev) = c_next;
> +		    }
> +		}

This doesn't really scale.  Consider 10000 clauses on various
oacc declare constructs in a single function, and 1000000 automatic
variables in such a function.
So, what I'm suggesting is during gimplification of OACC_DECLARE,
if you find a clause on an automatic variable in the current function
that you want to unmap afterwards, have a
static hash_map<tree, tree> *oacc_declare_returns;
and you just add into the hash map the VAR_DECL -> the clause you want,
then in this spot you check
  if (oacc_declare_returns)
    {
      clause = lookup in hash_map (t);
      if (clause)
	{
	  ...
	}
    }

> +
> +	      if (clauses == NULL)
> +		{
> +		  DECL_ATTRIBUTES (current_function_decl) =
> +			    remove_attribute ("oacc declare returns",
> +				    DECL_ATTRIBUTES (current_function_decl));

Wrong formatting.

	Jakub

  reply	other threads:[~2015-11-09 16:21 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-27 20:20 James Norris
2015-10-28 16:33 ` Cesar Philippidis
2015-10-28 16:33   ` James Norris
2015-11-03 16:31 ` James Norris
2015-11-04 16:49   ` Thomas Schwinge
2015-11-04 17:12     ` James Norris
2015-11-06 16:08     ` James Norris
2015-11-06 16:16       ` James Norris
2015-11-06 19:04       ` Jakub Jelinek
2015-11-06 19:23         ` Jakub Jelinek
2015-11-06 20:18           ` James Norris
2015-11-06 20:28             ` Jakub Jelinek
2015-11-06 20:35               ` James Norris
2015-11-06 20:16         ` James Norris
2015-11-08 15:35         ` James Norris
2015-11-09 16:01           ` James Norris
2015-11-09 16:21             ` Jakub Jelinek [this message]
2015-11-09 16:31               ` James Norris
2015-11-09 23:11               ` James Norris
2015-11-11  8:32                 ` Jakub Jelinek
2015-11-11 10:08                   ` Thomas Schwinge
2015-11-11 17:29                     ` Jakub Jelinek
2015-11-12  1:08                   ` James Norris
2015-11-12  9:10                     ` Jakub Jelinek
2015-11-12 13:34                       ` James Norris
2015-11-23 12:41                         ` Thomas Schwinge
2015-11-24  8:45                           ` [gomp4] " Thomas Schwinge
2015-11-12 23:25                             ` [PATCH] Fix unused variable James Norris
2015-11-22 19:11                               ` [PATCH] fortran/openmp.c -- Fix bootstrap Steve Kargl
2015-11-22 19:27                                 ` Jerry DeLisle
2015-11-22 20:38                                 ` James Norris
2019-06-18 22:45                           ` [committed] Fix description of 'GOMP_MAP_FIRSTPRIVATE' (was: [OpenACC] declare directive) Thomas Schwinge
2019-06-18 22:21                     ` [committed] [PR90862] OpenACC 'declare' ICE when nested inside another construct " Thomas Schwinge
2015-11-06 13:48 ` [OpenACC] declare directive James Norris
2021-06-10 11:15 ` Thomas Schwinge
2015-11-02 13:46 OpenACC declare directive updates James Norris
2015-11-04 12:32 ` James Norris
2015-11-06 13:46   ` James Norris
2015-11-06 19:31   ` Jakub Jelinek
2015-11-06 19:45     ` James Norris
2015-11-06 19:49       ` Jakub Jelinek
2015-11-06 20:20         ` James Norris
2015-11-19 16:22         ` James Norris
2015-11-20 10:53           ` Jakub Jelinek
2015-11-27 11:41           ` [gomp4] " Thomas Schwinge
2019-06-18 23:02             ` [committed] [PR85221] Set 'omp declare target', 'omp declare target link' attributes for Fortran OpenACC 'declare'd variables (was: [gomp4] Re: OpenACC declare directive updates) Thomas Schwinge
2015-11-08 15:29       ` OpenACC declare directive updates James Norris
2015-11-09  2:30         ` Cesar Philippidis
2015-11-09  4:53           ` James Norris
2015-11-18 20:09             ` Cesar Philippidis
2015-11-11 19:43 [OpenACC] declare directive Dominique d'Humières

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=20151109162117.GU5675@tucnak.redhat.com \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jnorris@codesourcery.com \
    --cc=joseph@codesourcery.com \
    --cc=thomas@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).