public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/omp/gcc-12] Given OpenACC 'async', defer 'free' of non-contiguous array support data structures [PR76739]
Date: Fri, 24 Mar 2023 15:12:56 +0000 (GMT)	[thread overview]
Message-ID: <20230324151256.B93003858C50@sourceware.org> (raw)

https://gcc.gnu.org/g:a1f6758ae08fa748b291954371859e0158d4d667

commit a1f6758ae08fa748b291954371859e0158d4d667
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Wed Mar 15 13:34:02 2023 +0100

    Given OpenACC 'async', defer 'free' of non-contiguous array support data structures [PR76739]
    
    Fix-up for og12 commit 15d0f61a7fecdc8fd12857c40879ea3730f6d99f
    "Merge non-contiguous array support patches".
    
            PR other/76739
            libgomp/
            * oacc-parallel.c (GOACC_parallel_keyed): Given OpenACC 'async',
            defer 'free' of non-contiguous array support data structures.
            * target.c (gomp_map_vars_internal): Likewise.

Diff:
---
 libgomp/ChangeLog.omp   | 7 +++++++
 libgomp/oacc-parallel.c | 5 ++++-
 libgomp/target.c        | 6 +++++-
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index ace54f2f82f..85ebab14ba8 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -1,3 +1,10 @@
+2023-03-24  Thomas Schwinge  <thomas@codesourcery.com>
+
+	PR other/76739
+	* oacc-parallel.c (GOACC_parallel_keyed): Given OpenACC 'async',
+	defer 'free' of non-contiguous array support data structures.
+	* target.c (gomp_map_vars_internal): Likewise.
+
 2023-03-23  Tobias Burnus  <tobias@codesourcery.com>
 
 	* testsuite/libgomp.fortran/map-alloc-comp-8.f90: New test.
diff --git a/libgomp/oacc-parallel.c b/libgomp/oacc-parallel.c
index 9cd99b4a0b4..136702d6e61 100644
--- a/libgomp/oacc-parallel.c
+++ b/libgomp/oacc-parallel.c
@@ -470,7 +470,10 @@ GOACC_parallel_keyed (int flags_m, void (*fn) (void *),
     = goacc_map_vars (acc_dev, aq, mapnum, hostaddrs, NULL, sizes, kinds,
 		      nca_info, true, GOMP_MAP_VARS_TARGET);
 
-  free (nca_info);
+  if (aq == NULL)
+    free (nca_info);
+  else
+    acc_dev->openacc.async.queue_callback_func (aq, free, nca_info);
 
   if (profiling_p)
     {
diff --git a/libgomp/target.c b/libgomp/target.c
index 96ece0b31fd..aaa597f6610 100644
--- a/libgomp/target.c
+++ b/libgomp/target.c
@@ -1938,7 +1938,11 @@ gomp_map_vars_internal (struct gomp_device_descr *devicep,
 		    (nca, target_ptrblock);
 		  gomp_copy_host2dev (devicep, aq, target_ptrblock, ptrblock,
 				      nca->ptrblock_size, false, cbufp);
-		  free (ptrblock);
+		  if (aq)
+		    /* Free once the transfer has completed.  */
+		    devicep->openacc.async.queue_callback_func (aq, free, ptrblock);
+		  else
+		    free (ptrblock);
 		}
 	    }
 	}

                 reply	other threads:[~2023-03-24 15:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230324151256.B93003858C50@sourceware.org \
    --to=tschwinge@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /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).