]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Given OpenACC 'async', defer 'free' of non-contiguous array support data structures...
authorThomas Schwinge <thomas@codesourcery.com>
Wed, 15 Mar 2023 12:34:02 +0000 (13:34 +0100)
committerThomas Schwinge <thomas@codesourcery.com>
Fri, 24 Mar 2023 15:11:56 +0000 (16:11 +0100)
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.

libgomp/ChangeLog.omp
libgomp/oacc-parallel.c
libgomp/target.c

index ace54f2f82f8144c3c15c6db6da079d151982986..85ebab14ba84ff9c9912bb664f869761af5cd8cc 100644 (file)
@@ -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.
index 9cd99b4a0b45318831e0fb114f319d54726ee4d4..136702d6e61e53db4310fdd2b4f6847f8b57334d 100644 (file)
@@ -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)
     {
index 96ece0b31fd4433ac104b281c7c614ccfc41aba1..aaa597f66101aa8988bc9054bb5a040d7ec754a4 100644 (file)
@@ -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);
                }
            }
        }