Investigating PR95590, I realised that we can do better at diagnosing some potentially troublesome usage of OpenACC "attach" behaviour, namely updating blocks with attached pointers. Updating either the host copy or device copy of such a block is problematic -- for a host update, the host may get a clobbered (device) version of a host pointer in its local version of the block (e.g. struct). A device update may clobber an attached device pointer with a host pointer.
The spec text (OpenACC 3.0, "2.6.8. Attachment Counter") covering this case is: "Pointer members of structs, classes, or derived types in device or host memory can be overwritten due to update directives or API routines. It is the user’s responsibility to ensure that the pointers have the appropriate values before or after the data movement in either direction. The behavior of the program is undefined if any of the pointer members are attached when an update of a composite variable is performed." The first patch in this series addresses that paragraph by making such updates (as well as copyouts, similarly) be runtime errors. The same text *might* also be an argument _against_ the fix in the second patch, though that is perhaps debatable (further discussion on that patch). Tested with offloading to NVPTX. OK? Julian Julian Brown (2): [OpenACC] Refuse update/copyout for blocks with attached pointers [OpenACC] Detect pointer updates for attach operations (PR95590) libgomp/oacc-mem.c | 42 +++++++++-- libgomp/target.c | 56 ++++++++++++-- .../attach-ptr-change-1.c | 74 +++++++++++++++++++ .../copyback-attached-dynamic-1.c | 31 ++++++++ .../copyback-attached-structural-1.c | 30 ++++++++ .../copyback-attached-structural-2.c | 31 ++++++++ .../copyback-attached-structural-3.c | 26 +++++++ .../delete-attached-dynamic-1.c | 26 +++++++ .../delete-attached-structural-1.c | 25 +++++++ .../delete-attached-structural-2.c | 26 +++++++ .../update-attached-1.c | 33 +++++++++ .../deep-copy-6-no_finalize.F90 | 6 +- 12 files changed, 390 insertions(+), 16 deletions(-) create mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/attach-ptr-change-1.c create mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/copyback-attached-dynamic-1.c create mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/copyback-attached-structural-1.c create mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/copyback-attached-structural-2.c create mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/copyback-attached-structural-3.c create mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/delete-attached-dynamic-1.c create mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/delete-attached-structural-1.c create mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/delete-attached-structural-2.c create mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/update-attached-1.c -- 2.23.0