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>
Cc: Thomas Schwinge <thomas@codesourcery.com>,
	gcc-patches@gcc.gnu.org,
	       Kirill Yukhin <kirill.yukhin@gmail.com>
Subject: Re: [gomp4.1] Handle new form of #pragma omp declare target
Date: Mon, 26 Oct 2015 19:55:00 -0000	[thread overview]
Message-ID: <20151026194940.GZ478@tucnak.redhat.com> (raw)
In-Reply-To: <20151026193904.GE35077@msticlxl57.ims.intel.com>

On Mon, Oct 26, 2015 at 10:39:04PM +0300, Ilya Verbin wrote:
> > Without declare target link or to, you can't use the global variables
> > in orphaned accelerated routines (unless you e.g. take the address of the
> > mapped variable in the region and pass it around).
> > The to variables (non-deferred) are always mapped and are initialized with
> > the original initializer, refcount is infinity.  link (deferred) work more
> > like the normal mapping, referencing those vars when they aren't explicitly
> > (or implicitly) mapped is unspecified behavior, if it is e.g. mapped freshly
> > with to kind, it gets the current value of the host var rather than the
> > original one.  But, beyond the mapping the compiler needs to ensure that
> > all uses of the link global var (or perhaps just all uses of the link global
> > var outside of the target construct body where it is mapped, because you
> > could use there the pointer you got from GOMP_target) are replaced by
> > dereference of some artificial pointer, so a becomes *a_tmp and &a becomes
> > &*a_tmp, and that the runtime library during registration of the tables is
> > told about the address of this artificial pointer.  During registration,
> > I'd expect it would stick an entry for this range into the table, with some
> > special flag or something similar, indicating that it is deferred mapping
> > and where the offloading device pointer is.  During mapping, it would map it
> > as any other not yet mapped object, but additionally would also set this
> > device pointer to the device address of the mapped object.  We also need to
> > ensure that when we drop the refcount of that mapping back to 0, we get it
> > back to the state where it is described as a range with registered deferred
> > mapping and where the device pointer is.
> 
> Ok, got it, I'll try implement this...

Thanks.

> > > > we actually replace the variables with pointers to variables, then need
> > > > to somehow also mark those in the offloading tables, so that the library
> > > 
> > > I see 2 possible options: use the MSB of the size, or introduce the third field
> > > for flags.
> > 
> > Well, it can be either recorded in the host variable tables (which contain
> > address and size pair, right), or in corresponding offloading device table
> > (which contains the pointer, something else?).
> 
> It contains a size too, which is checked in libgomp:
> 	  gomp_fatal ("Can't map target variables (size mismatch)");
> Yes, we can remove this check, and use second field in device table for flags.

Yeah, or e.g. just use MSB of that size (so check that either the size is
the same (then it is target to) or it is MSB | size (then it is target link).
Objects larger than half of the address space aren't really supportable
anyway.

	Jakub

  reply	other threads:[~2015-10-26 19:49 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-17 13:43 Jakub Jelinek
2015-07-17 15:48 ` James Norris
2015-10-26 18:45 ` Ilya Verbin
2015-10-26 19:11   ` Jakub Jelinek
2015-10-26 19:49     ` Ilya Verbin
2015-10-26 19:55       ` Jakub Jelinek [this message]
2015-11-16 15:41         ` [gomp4.5] Handle #pragma omp declare target link Ilya Verbin
2015-11-19 15:31           ` Jakub Jelinek
2015-11-27 16:51             ` Ilya Verbin
2015-11-30 12:08               ` Jakub Jelinek
2015-11-30 20:42                 ` Ilya Verbin
2015-11-30 20:55                   ` Jakub Jelinek
2015-11-30 21:38                     ` Ilya Verbin
2015-12-01  8:18                       ` Jakub Jelinek
2015-12-01  8:48                         ` Ilya Verbin
2015-12-01 13:16                           ` Jakub Jelinek
2015-12-01 17:30                             ` Ilya Verbin
2015-12-01 19:05                               ` Jakub Jelinek
2015-12-08 14:46                                 ` Ilya Verbin
2015-12-11 17:27                                   ` Jakub Jelinek
2015-12-11 17:46                                     ` Ilya Verbin
2015-12-14 16:48                                     ` Ilya Verbin
2015-12-16 12:30                                       ` gomp_target_fini (was: [gomp4.5] Handle #pragma omp declare target link) Thomas Schwinge
2015-12-23 11:05                                         ` gomp_target_fini Thomas Schwinge
2016-01-11 10:40                                           ` gomp_target_fini Thomas Schwinge
2016-01-21  6:17                                             ` gomp_target_fini Thomas Schwinge
2016-01-21 15:24                                         ` gomp_target_fini Bernd Schmidt
2016-01-22 10:16                                           ` gomp_target_fini Jakub Jelinek
2016-01-25 18:23                                             ` gomp_target_fini Mike Stump
2016-04-19 14:01                                             ` gomp_target_fini Thomas Schwinge
2016-04-19 14:04                                               ` gomp_target_fini Jakub Jelinek
2016-04-21 13:43                                                 ` gomp_target_fini Alexander Monakov
2016-04-21 15:38                                                   ` gomp_target_fini Thomas Schwinge
2016-04-19 15:23                                               ` gomp_target_fini Alexander Monakov
2015-12-14 17:18                     ` [gomp4.5] Handle #pragma omp declare target link Ilya Verbin
2015-12-15  8:42                       ` Jakub Jelinek
2015-12-16 16:21                       ` Thomas Schwinge
2016-01-07 18:57                         ` [gomp4] Fix use of declare'd vars by routine procedures James Norris
2016-01-11 11:55                           ` Thomas Schwinge
2016-01-11 15:38                             ` James Norris
2019-06-26 16:23                       ` [gomp4.5] Handle #pragma omp declare target link Thomas Schwinge
2015-10-27 21:15 ` [gomp4.1] Handle new form of #pragma omp declare target Ilya Verbin
2015-10-30 17:48   ` Ilya Verbin
2015-10-30 19:23     ` Jakub Jelinek
2015-11-02 16:54       ` Ilya Verbin
2015-11-02 18:01         ` Jakub Jelinek
2015-11-23 11:33 ` Thomas Schwinge
2015-11-23 11:41   ` 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=20151026194940.GZ478@tucnak.redhat.com \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=iverbin@gmail.com \
    --cc=kirill.yukhin@gmail.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).