From patchwork Thu Sep 19 13:59:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 1164668 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-509295-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="NHld/9vI"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46Yz4J54ZJz9s7T for ; Thu, 19 Sep 2019 23:59:42 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version :content-transfer-encoding:content-type; q=dns; s=default; b=GR0 SXuMmJILf4fHS+6u9bvBTzrID94LRmtZjPECAUHpLY/tG62qS+yIit+lXDQ6NgtR 8urJ4yGoR86igF7jYT+mKz3mgi3+n10vxhiyB/mc4VQPdoRObUYfdR43z4xIXny9 nKR6dYMaC8kldyOpYLV51muSB1Xl4CRyxUD9gZAE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version :content-transfer-encoding:content-type; s=default; bh=4cvLMUyhS FovqX3EU64GEt1aIvI=; b=NHld/9vIWeaRL3oFLTVbP+yu59vigAzwwXfBKil/S Isju2VmH9J6EOqU1Ka8GBzHkrJ7oOmgg+xvPuFhXHPWDxoWbfy3CK0uFXtmzoX9c 33Bxa/6NPeE5T7MxrnP5m90uEG3k5ueiuEt56z3/Ew9Bz+QUrTgwT0b8zEO9xGBM WA= Received: (qmail 52951 invoked by alias); 19 Sep 2019 13:59:35 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 52942 invoked by uid 89); 19 Sep 2019 13:59:35 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SUBJ_OBFU_PUNCT_FEW, SUBJ_OBFU_PUNCT_MANY autolearn=ham version=3.3.1 spammy=2220, investigate, ord, HContent-Transfer-Encoding:8bit X-HELO: esa4.mentor.iphmx.com Received: from esa4.mentor.iphmx.com (HELO esa4.mentor.iphmx.com) (68.232.137.252) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 19 Sep 2019 13:59:34 +0000 IronPort-SDR: wNr6SuZhulrPqYo8YwikeC/4ce5RS5UW3ulycDEzLnW+uAc64lII3eCFhLd4PN/rCgaFWkckIt rO+K9KFz4pgnJxRK/D7lwgkg0IImJES2wTPPDdRtYxdHcsVZJk2epjcViL2xZCoFwXnS/7TBAM mFz3SiAgs+EQZROP+jvHqe/wgYGu+HJctRyrC3AauXM/eze9fExCUMw8QBvg2pFf7yCOjOh2AX KJ13qHCdk6qf8Qt7CV8DvMknUmzOGFUWu7NWgkaHhs/9/cvx47a2ONI7yu6YghKYs6r0sWkUi7 Gik= Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 19 Sep 2019 05:59:32 -0800 IronPort-SDR: FYj14nC6evXxAQVQI51X0G4MlShjYUuiYw11ITg8bzLCynjkCAZe11RVLEbzlWo/+N/eHHefLq XTVVXELpx/pKyq631FjZzOfhv95uWYJXVPu9lJCcLTSKczQ56/O1ivw6L+GgHKveNfClcnIL2R K8AZRp/ZcsBcdlVmTb1TfQ6TSS3t0poRw/cTNpWwQfjyXju90uVav84o4BSSAXbe/pvqaqnfb8 B97aK4ZfR/WdH9qZ8lbbN3Sk4T2V4A7buvaYp8Vn6d6wyx2y43Luke/4lE6/098JXtaXCJpPY+ BRE= From: Julian Brown To: CC: Thomas Schwinge , Tobias Burnus Subject: [PATCH] [og9] Add 'ephemeral' parameter to GOMP_OFFLOAD_openacc_async_host2dev Date: Thu, 19 Sep 2019 06:59:13 -0700 Message-ID: <20190919135913.120673-1-julian@codesourcery.com> MIME-Version: 1.0 X-IsSubscribed: yes 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 + + * plugin/plugin-nvptx.c (GOMP_OFFLOAD_openacc_async_host2dev): + Add EPHEMERAL parameter, and FIXME function comment. + 2019-09-18 Tobias Burnus * 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))