This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] [og9] Add 'ephemeral' parameter to GOMP_OFFLOAD_openacc_async_host2dev
- From: Julian Brown <julian at codesourcery dot com>
- To: <gcc-patches at gcc dot gnu dot org>
- Cc: Thomas Schwinge <thomas_schwinge at mentor dot com>, Tobias Burnus <tobias at codesourcery dot com>
- Date: Thu, 19 Sep 2019 06:59:13 -0700
- Subject: [PATCH] [og9] Add 'ephemeral' parameter to GOMP_OFFLOAD_openacc_async_host2dev
- Ironport-sdr: wNr6SuZhulrPqYo8YwikeC/4ce5RS5UW3ulycDEzLnW+uAc64lII3eCFhLd4PN/rCgaFWkckIt rO+K9KFz4pgnJxRK/D7lwgkg0IImJES2wTPPDdRtYxdHcsVZJk2epjcViL2xZCoFwXnS/7TBAM mFz3SiAgs+EQZROP+jvHqe/wgYGu+HJctRyrC3AauXM/eze9fExCUMw8QBvg2pFf7yCOjOh2AX KJ13qHCdk6qf8Qt7CV8DvMknUmzOGFUWu7NWgkaHhs/9/cvx47a2ONI7yu6YghKYs6r0sWkUi7 Gik=
- Ironport-sdr: FYj14nC6evXxAQVQI51X0G4MlShjYUuiYw11ITg8bzLCynjkCAZe11RVLEbzlWo/+N/eHHefLq XTVVXELpx/pKyq631FjZzOfhv95uWYJXVPu9lJCcLTSKczQ56/O1ivw6L+GgHKveNfClcnIL2R K8AZRp/ZcsBcdlVmTb1TfQ6TSS3t0poRw/cTNpWwQfjyXju90uVav84o4BSSAXbe/pvqaqnfb8 B97aK4ZfR/WdH9qZ8lbbN3Sk4T2V4A7buvaYp8Vn6d6wyx2y43Luke/4lE6/098JXtaXCJpPY+ BRE=
This patch fixes a build failure in the NVPTX libgomp plugin after the
EPHEMERAL parameter was added to the GOMP_OFFLOAD_openacc_async_host2dev
plugin entry point.
So far the parameter is ignored, which is no change from the previous
behaviour but which I think may lead to a data race in some (presumably
rare) circumstances -- for reasons I describe in the FIXME comment added
to the function.
I will apply this to the openacc-gcc-9-branch shortly (to unbreak the
build), and investigate further.
Julian
ChangeLog
libgomp/
* plugin/plugin-nvptx.c (GOMP_OFFLOAD_openacc_async_host2dev):
Add EPHEMERAL parameter, and FIXME function comment.
---
libgomp/ChangeLog.openacc | 5 +++++
libgomp/plugin/plugin-nvptx.c | 13 ++++++++++++-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/libgomp/ChangeLog.openacc b/libgomp/ChangeLog.openacc
index 943a9e4a933..7813760e642 100644
--- a/libgomp/ChangeLog.openacc
+++ b/libgomp/ChangeLog.openacc
@@ -1,3 +1,8 @@
+2019-09-19 Julian Brown <julian@codesourcery.com>
+
+ * plugin/plugin-nvptx.c (GOMP_OFFLOAD_openacc_async_host2dev):
+ Add EPHEMERAL parameter, and FIXME function comment.
+
2019-09-18 Tobias Burnus <tobias@codesourcery.com>
* testsuite/libgomp.oacc-c-c++-common/parallel-dims.c: Fix dg-warning
diff --git a/libgomp/plugin/plugin-nvptx.c b/libgomp/plugin/plugin-nvptx.c
index 4beb3222e8f..452415e1879 100644
--- a/libgomp/plugin/plugin-nvptx.c
+++ b/libgomp/plugin/plugin-nvptx.c
@@ -1868,9 +1868,20 @@ GOMP_OFFLOAD_dev2dev (int ord, void *dst, const void *src, size_t n)
return true;
}
+/* FIXME: It is unknown whether the cuMemcpyHtoDAsync API call caches source
+ data before the asynchronous copy takes place. Either way there is a data
+ race associated with ignoring the EPHEMERAL parameter here -- either if it
+ is TRUE (because we are copying uncached data that may disappear before the
+ async copy takes place) or if it is FALSE (because the source data may be
+ cached/snapshotted here before it is modified by an earlier async operation,
+ so stale data gets copied to the target).
+ Neither problem has been observed in practice, so far. */
+
bool
GOMP_OFFLOAD_openacc_async_host2dev (int ord, void *dst, const void *src,
- size_t n, struct goacc_asyncqueue *aq)
+ size_t n,
+ bool ephemeral __attribute__((unused)),
+ struct goacc_asyncqueue *aq)
{
if (!nvptx_attach_host_thread_to_device (ord)
|| !cuda_memcpy_sanity_check (src, dst, n))
--
2.22.0