public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch] libgomp – fix declare target link handling (PR94251)
@ 2020-03-23 13:40 Tobias Burnus
  2020-03-23 14:02 ` Jakub Jelinek
  0 siblings, 1 reply; 2+ messages in thread
From: Tobias Burnus @ 2020-03-23 13:40 UTC (permalink / raw)
  To: gcc-patches, Jakub Jelinek

[-- Attachment #1: Type: text/plain, Size: 753 bytes --]

This patch fixes two issues:

(a) The target size is the pointer size and
host size is the variable size itself; thus, it fails often.

(b) Only the host variable has the link-var bit flip, hence,
we need to check this one not the target var's size.

With this patch, the test case passes on AMDGCN.
OK?

Tobias

PS:  Unfortunately, all those patches do not help with nvptx,
which still fails (PR 81689) at run-time startup with
ptxas /tmp/ccSRPv5o.o, line 120; error   : State space mismatch between instruction and address in instruction 'ld'

-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter

[-- Attachment #2: lib-target-var.diff --]
[-- Type: text/x-patch, Size: 1288 bytes --]

libgomp – fix declare target link handling (PR94251)

	PR libgomp/94251
	* target.c (gomp_load_image_to_device): Fix link
	variable handling.
	
diff --git a/libgomp/target.c b/libgomp/target.c
index 0ff727de47d..c99dd5196fa 100644
--- a/libgomp/target.c
+++ b/libgomp/target.c
@@ -1648,8 +1648,9 @@ gomp_load_image_to_device (struct gomp_device_descr *devicep, unsigned version,
     {
       struct addr_pair *target_var = &target_table[num_funcs + i];
       uintptr_t target_size = target_var->end - target_var->start;
+      bool is_link_var = link_bit & (uintptr_t) host_var_table[i * 2 + 1];
 
-      if ((uintptr_t) host_var_table[i * 2 + 1] != target_size)
+      if (!is_link_var && (uintptr_t) host_var_table[i * 2 + 1] != target_size)
 	{
 	  gomp_mutex_unlock (&devicep->lock);
 	  if (is_register_lock)
@@ -1663,7 +1664,7 @@ gomp_load_image_to_device (struct gomp_device_descr *devicep, unsigned version,
 	= k->host_start + (size_mask & (uintptr_t) host_var_table[i * 2 + 1]);
       k->tgt = tgt;
       k->tgt_offset = target_var->start;
-      k->refcount = target_size & link_bit ? REFCOUNT_LINK : REFCOUNT_INFINITY;
+      k->refcount = is_link_var ? REFCOUNT_LINK : REFCOUNT_INFINITY;
       k->virtual_refcount = 0;
       k->aux = NULL;
       array->left = NULL;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Patch] libgomp – fix declare target link handling (PR94251)
  2020-03-23 13:40 [Patch] libgomp – fix declare target link handling (PR94251) Tobias Burnus
@ 2020-03-23 14:02 ` Jakub Jelinek
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Jelinek @ 2020-03-23 14:02 UTC (permalink / raw)
  To: Tobias Burnus; +Cc: gcc-patches

On Mon, Mar 23, 2020 at 02:40:12PM +0100, Tobias Burnus wrote:
> This patch fixes two issues:
> 
> (a) The target size is the pointer size and
> host size is the variable size itself; thus, it fails often.
> 
> (b) Only the host variable has the link-var bit flip, hence,
> we need to check this one not the target var's size.
> 
> With this patch, the test case passes on AMDGCN.
> OK?

I'm puzzled on why it (probably?) happend to work when 4a38b02b4ed0
has been committed, given that the testcase did contain variables
in link clauses that didn't have pointer sizes themselves.

Anyway, your patch looks good to me.

> PS:  Unfortunately, all those patches do not help with nvptx,
> which still fails (PR 81689) at run-time startup with
> ptxas /tmp/ccSRPv5o.o, line 120; error   : State space mismatch between instruction and address in instruction 'ld'

Can you post the PTX assembly and perhaps some RTL dump?

> libgomp – fix declare target link handling (PR94251)
> 
> 	PR libgomp/94251
> 	* target.c (gomp_load_image_to_device): Fix link
> 	variable handling.

Thanks.

	Jakub


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-23 14:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-23 13:40 [Patch] libgomp – fix declare target link handling (PR94251) Tobias Burnus
2020-03-23 14:02 ` Jakub Jelinek

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).