public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Ilya Verbin <iverbin@gmail.com>,
	Alexander Monakov <amonakov@ispras.ru>,
	       Nathan Sidwell <nathan@acm.org>,
	       Thomas Schwinge <thomas_schwinge@mentor.com>,
	Jan Hubicka <jh@suse.cz>
Cc: gcc-patches@gcc.gnu.org
Subject: "omp declare target" on DECL_EXTERNAL vars
Date: Fri, 20 May 2016 16:21:00 -0000	[thread overview]
Message-ID: <20160520162120.GO28550@tucnak.redhat.com> (raw)
In-Reply-To: <20160520161244.GN28550@tucnak.redhat.com>

Hi!

While working on this patch, I've noticed the need to do:

On Fri, May 20, 2016 at 06:12:44PM +0200, Jakub Jelinek wrote:
> 	* varpool.c (varpool_node::get_create): Set node->offloading
> 	even for DECL_EXTERNAL decls.
...
> --- gcc/varpool.c.jj	2016-05-04 18:43:25.000000000 +0200
> +++ gcc/varpool.c	2016-05-20 12:18:14.636755302 +0200
> @@ -149,11 +149,11 @@ varpool_node::get_create (tree decl)
>    node = varpool_node::create_empty ();
>    node->decl = decl;
>  
> -  if ((flag_openacc || flag_openmp) && !DECL_EXTERNAL (decl)
> +  if ((flag_openacc || flag_openmp)
>        && lookup_attribute ("omp declare target", DECL_ATTRIBUTES (decl)))
>      {
>        node->offloadable = 1;
> -      if (ENABLE_OFFLOADING)
> +      if (ENABLE_OFFLOADING && !DECL_EXTERNAL (decl))
>  	{
>  	  g->have_offload = true;
>  	  if (!in_lto_p)

but that made me think on what handling do we want for the
"omp declare target" DECL_EXTERNAL vars.
The reason I needed the above is that both gimplify.c and omp-low.c
test just the node->offloadable flag, bit the attribute, and so when
it is external and the flag wasn't set, we could privatize the vars
even when we were supposed to map them etc.
In the C/C++ FEs, we set not just node->offloadable, but also
for ENABLE_OFFLOADING g->have_offload and offload_vars too.
Wonder if that means we register even non-local vars, that would be IMHO a
bug.  On the other side, we need to watch for an extern declaration
of a VAR_DECL marked for offloading and only later on locally defined,
in that case if we haven't set g->have_offload and added entry to
offload_vars, we'd need to do it when merging the extern decl with the
definition.

So, your thoughts on that?

	Jakub

  reply	other threads:[~2016-05-20 16:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-20 16:12 [gomp4.5] Make even Fortran target use firstprivate for scalars by default, assorted fixes Jakub Jelinek
2016-05-20 16:21 ` Jakub Jelinek [this message]
2016-05-23 14:37   ` "omp declare target" on DECL_EXTERNAL vars Alexander Monakov
2016-05-23 14:55     ` Jakub Jelinek
2016-05-23 16:15   ` Alexander Monakov
2016-05-23 16:51     ` Jakub Jelinek
2016-05-23 18:19       ` Alexander Monakov
2016-05-23 18:28         ` Jakub Jelinek

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=20160520162120.GO28550@tucnak.redhat.com \
    --to=jakub@redhat.com \
    --cc=amonakov@ispras.ru \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=iverbin@gmail.com \
    --cc=jh@suse.cz \
    --cc=nathan@acm.org \
    --cc=thomas_schwinge@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).