public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ilya Verbin <iverbin@gmail.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: gcc-patches@gcc.gnu.org, Kirill Yukhin <kirill.yukhin@gmail.com>
Subject: Re: [gomp4.5] Handle #pragma omp declare target link
Date: Mon, 30 Nov 2015 21:38:00 -0000	[thread overview]
Message-ID: <20151130205520.GB22962@msticlxl57.ims.intel.com> (raw)
In-Reply-To: <20151130204902.GJ5675@tucnak.redhat.com>

On Mon, Nov 30, 2015 at 21:49:02 +0100, Jakub Jelinek wrote:
> On Mon, Nov 30, 2015 at 11:29:34PM +0300, Ilya Verbin wrote:
> > You're right, it doesn't deallocate memory on the device if DSO leaves nonzero
> > refcount.  And currently host compiler doesn't set MSB in host_var_table, it's
> > set only by accel compiler.  But it's possible to do splay_tree_lookup for each
> > var to determine whether is it linked or not, like in the patch bellow.
> > Or do you prefer to set the bit in host compiler too?  It requires
> > lookup_attribute ("omp declare target link") for all vars in the table during
> > compilation, but allows to do splay_tree_lookup at run-time only for vars with
> > MSB set in host_var_table.
> > Unfortunately, calling gomp_exit_data from gomp_unload_image_from_device works
> > only for DSO, but it crashed when an executable leaves nonzero refcount, because
> > target device may be already uninitialized from plugin's __run_exit_handlers
> > (and it is in case of intelmic), so gomp_exit_data cannot run free_func.
> > Is it possible do add some atexit (...) to libgomp, which will set shutting_down
> > flag, and just do nothing in gomp_unload_image_from_device if it is set?
> 
> Sorry, I didn't mean you should call gomp_exit_data, what I meant was that
> you perform the same action as would delete(var) do in that case.
> Calling gomp_exit_data e.g. looks it up again etc.
> Supposedly having the MSB in host table too is useful, so if you could
> handle that, it would be nice.  And splay_tree_lookup only if the MSB is
> set.
> So,
>     if (!host_data_has_msb_set)
>       splay_tree_remove (&devicep->mem_map, &k);
>     else
>       {
>         splay_tree_key n = splay_tree_lookup (&devicep->mem_map, &k);
>         if (n->link_key)
> 	  {
> 	    n->refcount = 0;
> 	    n->link_key = NULL;
> 	    splay_tree_remove (&devicep->mem_map, n);
> 	    if (n->tgt->refcount > 1)
> 	      n->tgt->refcount--;
> 	    else
> 	      gomp_unmap_tgt (n->tgt);
> 	  }
> 	else
> 	  splay_tree_remove (&devicep->mem_map, n);
>       }
> or so.

Ok, but it doesn't solve the issue with doing it for the executable, because
gomp_unmap_tgt (n->tgt) will want to run free_func on uninitialized device.

  -- Ilya

  reply	other threads:[~2015-11-30 20:55 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-17 13:43 [gomp4.1] Handle new form of #pragma omp declare target 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
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 [this message]
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=20151130205520.GB22962@msticlxl57.ims.intel.com \
    --to=iverbin@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=kirill.yukhin@gmail.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).