In 'libgomp/target.c:gomp_exit_data', remove open-coded 'gomp_remove_var' (was: [OpenACC] Update OpenACC data clause semantics to the 2.5 behavior - runtime)
diff mbox series

Message ID 87tv693erj.fsf@euler.schwinge.homeip.net
State New
Headers show
Series
  • In 'libgomp/target.c:gomp_exit_data', remove open-coded 'gomp_remove_var' (was: [OpenACC] Update OpenACC data clause semantics to the 2.5 behavior - runtime)
Related show

Commit Message

Thomas Schwinge Dec. 9, 2019, 11:44 a.m. UTC
Hi!

On 2018-06-19T10:01:20-0700, Cesar Philippidis <cesar@codesourcery.com> wrote:
> --- a/libgomp/target.c
> +++ b/libgomp/target.c

> +attribute_hidden bool
> +gomp_remove_var (struct gomp_device_descr *devicep, splay_tree_key k)
> +{
> +  bool is_tgt_unmapped = false;
> +  splay_tree_remove (&devicep->mem_map, k);
> +  if (k->link_key)
> +    splay_tree_insert (&devicep->mem_map, (splay_tree_node) k->link_key);
> +  if (k->tgt->refcount > 1)
> +    k->tgt->refcount--;
> +  else
> +    {
> +      is_tgt_unmapped = true;
> +      gomp_unmap_tgt (k->tgt);
> +    }
> +  return is_tgt_unmapped;

This new function, can, like done here:

> @@ -1059,16 +1077,7 @@ gomp_unmap_vars (struct target_mem_desc *tgt, bool do_copyfrom)
>  				      + tgt->list[i].offset),
>  			    tgt->list[i].length);
>        if (do_unmap)
> -	{
> -	  splay_tree_remove (&devicep->mem_map, k);
> -	  if (k->link_key)
> -	    splay_tree_insert (&devicep->mem_map,
> -			       (splay_tree_node) k->link_key);
> -	  if (k->tgt->refcount > 1)
> -	    k->tgt->refcount--;
> -	  else
> -	    gomp_unmap_tgt (k->tgt);
> -	}
> +	gomp_remove_var (devicep, k);
>      }

..., and here:

> @@ -1298,17 +1307,7 @@ gomp_unload_image_from_device (struct gomp_device_descr *devicep,
>        else
>  	{
>  	  splay_tree_key n = splay_tree_lookup (&devicep->mem_map, &k);
> -	  splay_tree_remove (&devicep->mem_map, n);
> -	  if (n->link_key)
> -	    {
> -	      if (n->tgt->refcount > 1)
> -		n->tgt->refcount--;
> -	      else
> -		{
> -		  is_tgt_unmapped = true;
> -		  gomp_unmap_tgt (n->tgt);
> -		}
> -	    }
> +	  is_tgt_unmapped = gomp_remove_var (devicep, n);
>  	}

..., also be used in 'gomp_exit_data', see attached "In
'libgomp/target.c:gomp_exit_data', remove open-coded 'gomp_remove_var'",
committed to trunk in r279118.


Grüße
 Thomas

Patch
diff mbox series

From bbfdb255a0b5cb6e183e11026c2a482d4eeba981 Mon Sep 17 00:00:00 2001
From: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 9 Dec 2019 11:39:57 +0000
Subject: [PATCH] In 'libgomp/target.c:gomp_exit_data', remove open-coded
 'gomp_remove_var'

	libgomp/
	* target.c (gomp_exit_data): Use 'gomp_remove_var'.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@279118 138bc75d-0d04-0410-961f-82ee72b054a4
---
 libgomp/ChangeLog |  4 ++++
 libgomp/target.c  | 11 +----------
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index a0bd25177d1..c5541bcec81 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,3 +1,7 @@ 
+2019-12-09  Thomas Schwinge  <thomas@codesourcery.com>
+
+	* target.c (gomp_exit_data): Use 'gomp_remove_var'.
+
 2019-12-09  Tobias Burnus  <tobias@codesourcery.com>
 
 	* testsuite/libgomp.fortran/use_device_addr-3.f90: Make 'stop' codes
diff --git a/libgomp/target.c b/libgomp/target.c
index 84d6daa76ca..13f7921651f 100644
--- a/libgomp/target.c
+++ b/libgomp/target.c
@@ -2095,16 +2095,7 @@  gomp_exit_data (struct gomp_device_descr *devicep, size_t mapnum,
 					  - k->host_start),
 				cur_node.host_end - cur_node.host_start);
 	  if (k->refcount == 0)
-	    {
-	      splay_tree_remove (&devicep->mem_map, k);
-	      if (k->link_key)
-		splay_tree_insert (&devicep->mem_map,
-				   (splay_tree_node) k->link_key);
-	      if (k->tgt->refcount > 1)
-		k->tgt->refcount--;
-	      else
-		gomp_unmap_tgt (k->tgt);
-	    }
+	    gomp_remove_var (devicep, k);
 
 	  break;
 	default:
-- 
2.17.1