From patchwork Fri Jun 5 16:14:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 1304239 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49dnlc2H92z9sRK for ; Sat, 6 Jun 2020 02:14:19 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3D34D3851C3A; Fri, 5 Jun 2020 16:14:16 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id 99E7C3851C28 for ; Fri, 5 Jun 2020 16:14:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 99E7C3851C28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Thomas_Schwinge@mentor.com IronPort-SDR: DwgNX6nIrD4S6lqzEztcUfh49Am9EI6K4mBBJx2Q+2ByacqxXCYlC54oEpWBstLx9DP9OJVN2f JV7MLCtaIfk+wF5RaSKEARF3B6iFwcFQKD90fEIOAytC3koSpX2qtzPkpG4aBELXNSP+1UIwsT tlZnSxNpEQFZhpxEFtpu66b6ETn67O5XAApJA+DMWQeP5uO7ZOyIpQQ3zxnFda297IuarYgNzG fVmxCKD0uZ1C8ZI9YkoAaAsq/9jEWksm0wRg1skSp2Bh1TTusNeBoj8zWIs+TaYZ0uSIf65+RO mXg= X-IronPort-AV: E=Sophos;i="5.73,476,1583222400"; d="scan'208,223";a="49552929" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 05 Jun 2020 08:14:12 -0800 IronPort-SDR: r8mzdxHkNwB8cMX6cU0AE4//b+E+A20qcNZ7pdMQiOSzeqd9vCa1R/TS2DgQ4mfIMGU3ON/IdY dmH6OKPp5XhXlTM5s1Bj5axbFfwZqBxcvqMUiJnjH6Quj4LJ2MHLyaFaNEt1MPXuQ65BEFpZfV F7qoAYS/gO4bGfxQ9O8S8AYJ5DJsxS+pKhaoH5KNrINXUtkCkaZ0dEtq5B1N6ZQKRglEAcpVgD 6N02xHmd0rKDBPFPLU7U2thLok7Ug45l38a9MpcfT0b+eMLRKtIS3eWrzSDLMoLwxU7crAWHLA hDk= From: Thomas Schwinge To: Julian Brown , Subject: Add 'libgomp.oacc-c-c++-common/struct-copyout-{1, 2}.c' (was: [PATCH 1/3] OpenACC "exit data" copyout for struct members) In-Reply-To: <6538c388d22e016bd01737e8c2f80437f432c70f.1591276990.git.julian@codesourcery.com> References: <87ftbw9kqh.fsf@euler.schwinge.homeip.net> <6538c388d22e016bd01737e8c2f80437f432c70f.1591276990.git.julian@codesourcery.com> User-Agent: Notmuch/0.29.1+93~g67ed7df (https://notmuchmail.org) Emacs/26.3 (x86_64-pc-linux-gnu) Date: Fri, 5 Jun 2020 18:14:00 +0200 Message-ID: <873679sd6f.fsf@euler.schwinge.homeip.net> MIME-Version: 1.0 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_LOTSOFHASH, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi! On 2020-06-04T06:40:53-0700, Julian Brown wrote: > [...] I've added a couple of new testcases to verify the behaviour > (which fail without the patch). Thanks. Given the preparational patches pushed yesterday, these now PASS already. > * testsuite/libgomp.oacc-c-c++-common/struct-copyout-1.c: New test. > * testsuite/libgomp.oacc-c-c++-common/struct-copyout-2.c: New test. Pushed "Add 'libgomp.oacc-c-c++-common/struct-copyout-{1,2}.c'" to master branch in commit 9643f5bbe237764cbefc975e934d1281f47ee3c2, and releases/gcc-10 branch in commit 52d737058897eb438099b57234d41330147d0b6f, see attached. Grüße Thomas ----------------- Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter From 52d737058897eb438099b57234d41330147d0b6f Mon Sep 17 00:00:00 2001 From: Julian Brown Date: Thu, 4 Jun 2020 06:40:53 -0700 Subject: [PATCH] Add 'libgomp.oacc-c-c++-common/struct-copyout-{1,2}.c' libgomp/ * testsuite/libgomp.oacc-c-c++-common/struct-copyout-1.c: New test. * testsuite/libgomp.oacc-c-c++-common/struct-copyout-2.c: New test. Reviewed-by: Thomas Schwinge (cherry picked from commit 9643f5bbe237764cbefc975e934d1281f47ee3c2) --- .../struct-copyout-1.c | 38 ++++++++++++++++ .../struct-copyout-2.c | 44 +++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/struct-copyout-1.c create mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/struct-copyout-2.c diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/struct-copyout-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/struct-copyout-1.c new file mode 100644 index 000000000000..b86f1c921a98 --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/struct-copyout-1.c @@ -0,0 +1,38 @@ +#include + +struct str1 { + int a; + int b; +}; + +struct str2 { + int c; + int d; + struct str1 s; +}; + +int +main (int argc, char *argv[]) +{ + struct str2 t; + + t.c = 1; + t.d = 2; + t.s.a = 3; + t.s.b = 4; + + #pragma acc enter data copyin(t.s) + + #pragma acc serial present(t.s) /* { dg-warning "using vector_length \\(32\\), ignoring 1" "" { target openacc_nvidia_accel_selected } } */ + { + t.s.a = 5; + t.s.b = 6; + } + + #pragma acc exit data copyout(t.s) + + assert (t.s.a == 5); + assert (t.s.b == 6); + + return 0; +} diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/struct-copyout-2.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/struct-copyout-2.c new file mode 100644 index 000000000000..4dd8a3a7e175 --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/struct-copyout-2.c @@ -0,0 +1,44 @@ +#include +#include + +struct str1 { + int a; + int b; + int *c; +}; + +#define N 1024 + +int +main (int argc, char *argv[]) +{ + struct str1 s; + + s.a = 1; + s.b = 2; + s.c = (int *) malloc (sizeof (int) * N); + + for (int i = 0; i < N; i++) + s.c[i] = i + 10; + + #pragma acc enter data copyin(s.a, s.b, s.c[0:N]) + + #pragma acc serial present(s.a, s.b, s.c[0:N]) /* { dg-warning "using vector_length \\(32\\), ignoring 1" "" { target openacc_nvidia_accel_selected } } */ + { + s.a = 3; + s.b = 4; + for (int i = 0; i < N; i++) + s.c[i] = i + 20; + } + + #pragma acc exit data copyout(s.a, s.b, s.c[0:N]) + + assert (s.a == 3); + assert (s.b == 4); + for (int i = 0; i < N; i++) + assert (s.c[i] == i + 20); + + free (s.c); + + return 0; +} -- 2.26.2