]> git.ipfire.org Git - thirdparty/gcc.git/commit - libgomp/target.c
Fix OpenACC "ephemeral" asynchronous host-to-device copies
authorJulian Brown <julian@codesourcery.com>
Tue, 29 Jun 2021 23:42:03 +0000 (16:42 -0700)
committerThomas Schwinge <thomas@codesourcery.com>
Tue, 27 Jul 2021 09:16:27 +0000 (11:16 +0200)
commit9c41f5b9cddd93f1b56eb71bff87b255d37d16f4
tree575141d79a9a03bddcfef0c5eb5c6abeae5f1ad4
parent88c40c36db8a52d2c630aa61ee54e33908e9daec
Fix OpenACC "ephemeral" asynchronous host-to-device copies

This patch fixes several places in libgomp/target.c where "ephemeral" data
(on the stack or in temporary heap locations) may be used as the source of
an asynchronous host-to-device copy that may not complete before the host
data disappears.

An existing, but flawed, workaround for this problem in the AMD GCN
libgomp offloading plugin is currently present on mainline, and was
posted for the og9 branch here:

  https://gcc.gnu.org/legacy-ml/gcc-patches/2019-08/msg00901.html

and previous versions of this patch were posted here (for mainline/og9):

  https://gcc.gnu.org/legacy-ml/gcc-patches/2019-11/msg01482.html
  https://gcc.gnu.org/legacy-ml/gcc-patches/2019-09/msg01026.html

libgomp/
* libgomp.h (gomp_copy_host2dev): Update prototype.
* oacc-mem.c (memcpy_tofrom_device, update_dev_host): Add new
argument to gomp_copy_host2dev (false).
* plugin/plugin-gcn.c (struct copy_data): Remove free_src field.
(copy_data): Don't free src.
(queue_push_copy): Remove free_src handling.
(GOMP_OFFLOAD_dev2dev): Update call to queue_push_copy.
(GOMP_OFFLOAD_openacc_async_host2dev): Remove source-data
snapshotting.
(GOMP_OFFLOAD_openacc_async_dev2host): Update call to
queue_push_copy.
* target.c (goacc_device_copy_async): Add SRCADDR_ORIG parameter.
(gomp_copy_host2dev): Add EPHEMERAL parameter.  Snapshot source
data when true, and set up deferred freeing of temporary buffer.
(gomp_copy_dev2host): Update call to goacc_device_copy_async.
(gomp_map_vars_existing, gomp_map_pointer, gomp_attach_pointer)
(gomp_detach_pointer, gomp_map_vars_internal, gomp_update): Update
calls to gomp_copy_host2dev with appropriate ephemeral argument.
* testsuite/libgomp.oacc-c-c++-common/async-data-1-1.c: Remove
XFAIL.

Co-Authored-By: Thomas Schwinge <thomas@codesourcery.com>
libgomp/libgomp.h
libgomp/oacc-mem.c
libgomp/plugin/plugin-gcn.c
libgomp/target.c
libgomp/testsuite/libgomp.oacc-c-c++-common/async-data-1-1.c