public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Julian Brown <julian@codesourcery.com>
To: <gcc-patches@gcc.gnu.org>
Cc: Thomas Schwinge <thomas@codesourcery.com>,
	Jakub Jelinek <jakub@redhat.com>,
	Catherine Moore <clm@codesourcery.com>
Subject: [PATCH 0/2] [OpenACC] Attached deep-copy pointers, diagnostics & modifications
Date: Mon, 22 Jun 2020 05:14:42 -0700	[thread overview]
Message-ID: <cover.1592826181.git.julian@codesourcery.com> (raw)

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


             reply	other threads:[~2020-06-22 12:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-22 12:14 Julian Brown [this message]
2020-06-22 12:14 ` [PATCH 1/2] [OpenACC] Refuse update/copyout for blocks with attached pointers Julian Brown
2020-07-24 13:37   ` Thomas Schwinge
2020-06-22 12:14 ` [PATCH 2/2] [OpenACC] Detect pointer updates for attach operations (PR95590) Julian Brown
2020-07-24 14:04   ` Thomas Schwinge
2020-07-24 22:36     ` Julian Brown

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=cover.1592826181.git.julian@codesourcery.com \
    --to=julian@codesourcery.com \
    --cc=clm@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=thomas@codesourcery.com \
    /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).