public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Cesar Philippidis <cesar@codesourcery.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	       Nathan Sidwell <nathan_sidwell@mentor.com>
Subject: Re: openacc reference reductions
Date: Wed, 06 Apr 2016 14:23:00 -0000	[thread overview]
Message-ID: <20160406142340.GZ19207@tucnak.redhat.com> (raw)
In-Reply-To: <57046C2B.6080002@codesourcery.com>

On Tue, Apr 05, 2016 at 06:53:47PM -0700, Cesar Philippidis wrote:
> --- a/gcc/omp-low.c
> +++ b/gcc/omp-low.c
> @@ -309,6 +309,25 @@ is_oacc_kernels (omp_context *ctx)
>  	      == GF_OMP_TARGET_KIND_OACC_KERNELS));
>  }
>  
> +/* Return true if CTX corresponds to an oacc parallel region and if
> +   VAR is used in a reduction.  */
> +
> +static bool
> +is_oacc_parallel_reduction (tree var, omp_context *ctx)
> +{
> +  if (!is_oacc_parallel (ctx))
> +    return false;
> +
> +  tree clauses = gimple_omp_target_clauses (ctx->stmt);
> +
> +  for (tree c = clauses; c; c = OMP_CLAUSE_CHAIN (c))
> +    if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
> +	&& OMP_CLAUSE_DECL (c) == var)
> +      return true;
> +
> +  return false;
> +}
> +
>  /* If DECL is the artificial dummy VAR_DECL created for non-static
>     data member privatization, return the underlying "this" parameter,
>     otherwise return NULL.  */
> @@ -2122,7 +2141,8 @@ scan_sharing_clauses (tree clauses, omp_context *ctx,
>  		  else
>  		    install_var_field (decl, true, 3, ctx,
>  				       base_pointers_restrict);
> -		  if (is_gimple_omp_offloaded (ctx->stmt))
> +		  if (is_gimple_omp_offloaded (ctx->stmt)
> +		      && !is_oacc_parallel_reduction (decl, ctx))
>  		    install_var_local (decl, ctx);
>  		}
>  	    }

The above is O(n^2) in number of clauses on the construct.
Perhaps better define some OMP_CLAUSE_MAP_IN_REDUCTION macro (e.g.
TREE_PRIVATE bit is unused on OMP_CLAUSE_MAP right now), make sure to set it
e.g. during gimplification where you can see all GOVD_* flags for a
particular decl), and then use this flag here?


	Jakub

  reply	other threads:[~2016-04-06 14:23 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-09 15:14 Cesar Philippidis
2016-02-09 15:33 ` Nathan Sidwell
2016-02-09 16:17   ` Cesar Philippidis
2016-02-22 15:34     ` Cesar Philippidis
2016-02-22 16:23       ` Nathan Sidwell
2016-04-06  1:54       ` Cesar Philippidis
2016-04-06 14:23         ` Jakub Jelinek [this message]
2016-04-06 20:21           ` Cesar Philippidis
2016-04-07  9:57             ` Jakub Jelinek
2016-04-08  4:34               ` Cesar Philippidis
2016-04-08  7:41                 ` Jakub Jelinek
2016-04-08  7:44                   ` Jakub Jelinek
2016-04-08 14:14                   ` Nathan Sidwell
2016-04-08 14:21                     ` Jakub Jelinek
2016-04-08 14:46                     ` Cesar Philippidis
2016-04-08 14:49                       ` Nathan Sidwell
2016-04-08 14:35                   ` Cesar Philippidis
2016-04-08 15:30                     ` Jakub Jelinek
2021-04-26 10:35 ` [OpenACC] Don't compile libgomp testcases with '-w' (was: openacc reference reductions) 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=20160406142340.GZ19207@tucnak.redhat.com \
    --to=jakub@redhat.com \
    --cc=cesar@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=nathan_sidwell@mentor.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).