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

On Mon, May 23, 2016 at 07:15:48PM +0300, Alexander Monakov wrote:
> (it's unclear to me what you mean by 'non-local vars' here, from the context
> it looks like it's 'variables with an external declaration and no definition
> in the current TU'; correct?)

Sure.

> Looking at the OpenMP 4.5 spec, there's a requirement that
> 
>     [2.10.6 declare target directive, Restrictions, C/C++]
>     * All declarations and definitions for a function must have a declare
>     target directive if one is specified for any of them. Otherwise, the
>     result is unspecified.
> 
> (why are variables exempted?)

I'll ask on the lang committee.  That said, for external declarations of
variables, all we care is that if any external declaration is specified in
to/link clause on declare target directive, then the definition (for common
vars all the definitions I guess) are also specified in the same kind of
clause.

Having the externs specified in omp declare target to is important for
code generation, we need to know that whether the vars should be mapped
implicitly on target constructs and remapped in the target construct bodies,
or whether the actual vars should be used in the regions.

Thus, 

> So from that perspective it's undesirable to have 'omp declare target' on
> declarations that don't define anything.

is just wrong, we at least need the symbol_table::offloadable bit set.

About g->head_offload and offload_vars, I guess it is fine not to set those
for externs but we need to arrange that to be set when we actually define it
when it has been previously extern, and we need some sensible handling
of the case where the var is only declared extern and omp declare target,
used in some target region, but not actually defined anywhere in the same
shared library or executable.

	Jakub

  reply	other threads:[~2016-05-23 16:51 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 ` "omp declare target" on DECL_EXTERNAL vars Jakub Jelinek
2016-05-23 14:37   ` Alexander Monakov
2016-05-23 14:55     ` Jakub Jelinek
2016-05-23 16:15   ` Alexander Monakov
2016-05-23 16:51     ` Jakub Jelinek [this message]
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=20160523165110.GV28550@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).