From patchwork Wed Jun 7 11:26:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 1791651 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) 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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QblRz0xYnz20QH for ; Wed, 7 Jun 2023 21:27:11 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 284ED3856956 for ; Wed, 7 Jun 2023 11:27:09 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id 4C7F53858C54 for ; Wed, 7 Jun 2023 11:26:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4C7F53858C54 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="6.00,223,1681200000"; d="diff'?scan'208";a="8125207" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa4.mentor.iphmx.com with ESMTP; 07 Jun 2023 03:26:53 -0800 IronPort-SDR: J+51zX6MZbuq6IF5cIgHKBLmq2S/+AAqcxq4sjNrVWKZgGawZINNPDHusrDRVavunrJD89iRfd sN0beu6JSiOBQi8h4JnT+ztIrwpm4t8b6JRNhQz8kmq/81btnEQbO2HUFpHN9ISvEWjJX/bROp YplcSJsSuEROe1wqsMyFW7Zosm+d3pswlBumtQYM3CQVCpTLAfc9XP/rYYOxuW3v5cMCMSjH/O L5quoBpmJrUM+wzZCKrhkENWuUUISyRV7B91BlXCnIvQbl6e0wPzN4cihmZc7QGBdqWLVLU5WD cj8= Message-ID: Date: Wed, 7 Jun 2023 13:26:48 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.2 Subject: [committed] testsuite/libgomp.*/target-present-*.{c, f90}: Improve and fix (was: Re: [og12] Fix 'libgomp.{c-c++-common, fortran}/target-present-*' test cases) Content-Language: en-US To: References: <049a4654-2596-1913-20fc-1aeea48eb3ec@codesourcery.com> <87bkluzr8q.fsf@euler.schwinge.homeip.net> CC: Thomas Schwinge From: Tobias Burnus In-Reply-To: <87bkluzr8q.fsf@euler.schwinge.homeip.net> X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) To svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This patch fixes a corner case issue (missing list items in a map clause) and ensures that such an issue is caught. Committed to mainline as https://gcc.gnu.org/r14-1605-gdd958667821e38 It is a forward port of Thomas' OG12 then OG13 commit which fixed a run-time issue which the mainline version does not have; still fixing the map issue (and doing the check-point check) is a good idea and, hence, a likewise patch has now been applied to mainline as well. OG13 commit: https://gcc.gnu.org/g:f719ab9a3ac51d798b012a5ab7757af2b81b4ae2 OG12 commit, see Thomas email earlier in this thread. Tobias On 15.02.23 20:02, Thomas Schwinge wrote: > On 2023-02-09T21:17:44+0000, Kwok Cheung Yeung wrote: >> [...] > I've pushed to devel/omp/gcc-12 branch > commit bbda035ee62ba4db21356136c97e9d83a97ba7d1 > "Fix 'libgomp.{c-c++-common,fortran}/target-present-*' test cases", > see attached. [...] ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 commit dd958667821e38b7d6b8efe448044901b4762b3a Author: Tobias Burnus Date: Wed Jun 7 13:22:13 2023 +0200 testsuite/libgomp.*/target-present-*.{c,f90}: Improve and fix One of the testcases lacked variables in a map clause such that the fail occurred too early. Additionally, it would have failed for all those non-host devices where 'present' is always true, i.e. non-host devices which can access all of the host memory (shared-memory devices). [There are currently none.] The commit now runs the code on all devices, which should succeed for host fallback and for shared-memory devices, finding potenial issues that way. Additionally, a checkpoint (required stdout output) is used to ensure that the execution won't fail (with the same error) before reaching the expected fail location. 2023-06-07 Thomas Schwinge Tobias Burnus libgomp/ * testsuite/libgomp.c-c++-common/target-present-1.c: Run code also for non-offload_device targets; check that it runs successfully for those and for all until a checkpoint for all * testsuite/libgomp.c-c++-common/target-present-2.c: Likewise. * testsuite/libgomp.c-c++-common/target-present-3.c: Likewise. * testsuite/libgomp.fortran/target-present-1.f90: Likewise. * testsuite/libgomp.fortran/target-present-3.f90: Likewise. * testsuite/libgomp.fortran/target-present-2.f90: Likewise; add missing vars to map clause. --- libgomp/testsuite/libgomp.c-c++-common/target-present-1.c | 9 ++++++--- libgomp/testsuite/libgomp.c-c++-common/target-present-2.c | 11 +++++++---- libgomp/testsuite/libgomp.c-c++-common/target-present-3.c | 9 +++++---- libgomp/testsuite/libgomp.fortran/target-present-1.f90 | 9 +++++---- libgomp/testsuite/libgomp.fortran/target-present-2.f90 | 13 +++++++------ libgomp/testsuite/libgomp.fortran/target-present-3.f90 | 9 +++++---- 6 files changed, 35 insertions(+), 25 deletions(-) diff --git a/libgomp/testsuite/libgomp.c-c++-common/target-present-1.c b/libgomp/testsuite/libgomp.c-c++-common/target-present-1.c index 12f154c91a8..aa343197e35 100644 --- a/libgomp/testsuite/libgomp.c-c++-common/target-present-1.c +++ b/libgomp/testsuite/libgomp.c-c++-common/target-present-1.c @@ -1,5 +1,4 @@ -/* { dg-do run { target offload_device } } */ -/* { dg-shouldfail "present error triggered" } */ +#include #define N 100 @@ -18,8 +17,12 @@ int main (void) for (int i = 0; i < N; i++) c[i] = a[i]; + fprintf (stderr, "CheCKpOInT\n"); + /* { dg-output "CheCKpOInT(\n|\r\n|\r).*" } */ + /* b has not been allocated, so this should result in an error. */ - /* { dg-output "libgomp: present clause: not present on the device \\\(0x\[0-9a-f\]+, \[0-9\]+\\\)" } */ + /* { dg-output "libgomp: present clause: not present on the device \\\(0x\[0-9a-f\]+, \[0-9\]+\\\)" { target offload_device_nonshared_as } } */ + /* { dg-shouldfail "present error triggered" { offload_device_nonshared_as } } */ #pragma omp target map (present, to: b) for (int i = 0; i < N; i++) c[i] += b[i]; diff --git a/libgomp/testsuite/libgomp.c-c++-common/target-present-2.c b/libgomp/testsuite/libgomp.c-c++-common/target-present-2.c index d4debbab10b..ad11023b2d6 100644 --- a/libgomp/testsuite/libgomp.c-c++-common/target-present-2.c +++ b/libgomp/testsuite/libgomp.c-c++-common/target-present-2.c @@ -1,5 +1,4 @@ -/* { dg-do run { target offload_device } } */ -/* { dg-shouldfail "present error triggered" } */ +#include #define N 100 @@ -13,13 +12,17 @@ int main (void) } #pragma omp target enter data map (alloc: a, c) - /* a has already been allocated, so this should be okay. */ + /* a and c have already been allocated, so this should be okay. */ #pragma omp target defaultmap (present) for (int i = 0; i < N; i++) c[i] = a[i]; + fprintf (stderr, "CheCKpOInT\n"); + /* { dg-output "CheCKpOInT(\n|\r\n|\r).*" } */ + /* b has not been allocated, so this should result in an error. */ - /* { dg-output "libgomp: present clause: not present on the device \\\(0x\[0-9a-f\]+, \[0-9\]+\\\)" } */ + /* { dg-output "libgomp: present clause: not present on the device \\\(0x\[0-9a-f\]+, \[0-9\]+\\\)" { target offload_device_nonshared_as } } */ + /* { dg-shouldfail "present error triggered" { offload_device_nonshared_as } } */ #pragma omp target defaultmap (present) for (int i = 0; i < N; i++) c[i] += b[i]; diff --git a/libgomp/testsuite/libgomp.c-c++-common/target-present-3.c b/libgomp/testsuite/libgomp.c-c++-common/target-present-3.c index 9d8d8f8a335..455519af405 100644 --- a/libgomp/testsuite/libgomp.c-c++-common/target-present-3.c +++ b/libgomp/testsuite/libgomp.c-c++-common/target-present-3.c @@ -1,6 +1,3 @@ -/* { dg-do run { target offload_device } } */ -/* { dg-shouldfail "present error triggered" } */ - #include #define N 100 @@ -19,8 +16,12 @@ int main (void) /* This should work as a has already been allocated. */ #pragma omp target update to (present: a) + fprintf (stderr, "CheCKpOInT\n"); + /* { dg-output "CheCKpOInT(\n|\r\n|\r).*" } */ + /* This should fail as b has not been allocated. */ - /* { dg-output "libgomp: present clause: not present on the device \\\(0x\[0-9a-f\]+, \[0-9\]+\\\)" } */ + /* { dg-output "libgomp: present clause: not present on the device \\\(0x\[0-9a-f\]+, \[0-9\]+\\\)" { target offload_device_nonshared_as } } */ + /* { dg-shouldfail "present error triggered" { offload_device_nonshared_as } } */ #pragma omp target update to (present: b) #pragma omp target exit data map (from: c) diff --git a/libgomp/testsuite/libgomp.fortran/target-present-1.f90 b/libgomp/testsuite/libgomp.fortran/target-present-1.f90 index 349dcb118b2..768166fcff7 100644 --- a/libgomp/testsuite/libgomp.fortran/target-present-1.f90 +++ b/libgomp/testsuite/libgomp.fortran/target-present-1.f90 @@ -1,6 +1,3 @@ -! { dg-do run { target offload_device } } -! { dg-shouldfail "present error triggered" } - program main implicit none integer, parameter :: N = 100 @@ -19,8 +16,12 @@ program main end do !$omp end target + print *, "CheCKpOInT" + ! { dg-output "CheCKpOInT(\n|\r\n|\r).*" } + ! b has not been allocated, so this should result in an error. - ! { dg-output "libgomp: present clause: not present on the device \\\(0x\[0-9a-f\]+, \[0-9\]+\\\)" } + ! { dg-output "libgomp: present clause: not present on the device \\\(0x\[0-9a-f\]+, \[0-9\]+\\\)" { target offload_device_nonshared_as } } + ! { dg-shouldfail "present error triggered" { offload_device_nonshared_as } } !$omp target map (present, to: b) do i = 1, N c(i) = c(i) + b(i) diff --git a/libgomp/testsuite/libgomp.fortran/target-present-2.f90 b/libgomp/testsuite/libgomp.fortran/target-present-2.f90 index 07e79d1b576..8f2c24ef5f2 100644 --- a/libgomp/testsuite/libgomp.fortran/target-present-2.f90 +++ b/libgomp/testsuite/libgomp.fortran/target-present-2.f90 @@ -1,6 +1,3 @@ -! { dg-do run { target offload_device } } -! { dg-shouldfail "present error triggered" } - program main implicit none integer, parameter :: N = 100 @@ -11,16 +8,20 @@ program main b(i) = i * 3 + 1 end do - !$omp target enter data map (alloc: a) - ! a has already been allocated, so this should be okay. + !$omp target enter data map (alloc: a, c, i) + ! a, c, and i have already been allocated, so this should be okay. !$omp target defaultmap (present) do i = 1, N c(i) = a(i) end do !$omp end target + print *, "CheCKpOInT" + ! { dg-output "CheCKpOInT(\n|\r\n|\r).*" } + ! b has not been allocated, so this should result in an error. - ! { dg-output "libgomp: present clause: not present on the device \\\(0x\[0-9a-f\]+, \[0-9\]+\\\)" } + ! { dg-output "libgomp: present clause: not present on the device \\\(0x\[0-9a-f\]+, \[0-9\]+\\\)" { target offload_device_nonshared_as } } + ! { dg-shouldfail "present error triggered" { offload_device_nonshared_as } } !$omp target defaultmap (present) do i = 1, N c(i) = c(i) + b(i) diff --git a/libgomp/testsuite/libgomp.fortran/target-present-3.f90 b/libgomp/testsuite/libgomp.fortran/target-present-3.f90 index a2709eb6f17..eb29c907624 100644 --- a/libgomp/testsuite/libgomp.fortran/target-present-3.f90 +++ b/libgomp/testsuite/libgomp.fortran/target-present-3.f90 @@ -1,6 +1,3 @@ -! { dg-do run { target offload_device } } -! { dg-shouldfail "present error triggered" } - program main implicit none integer, parameter :: N = 100 @@ -15,8 +12,12 @@ program main ! This should work as a has already been allocated. !$omp target update to (present: a) + print *, "CheCKpOInT" + ! { dg-output "CheCKpOInT(\n|\r\n|\r).*" } + ! This should fail as b has not been allocated. - ! { dg-output "libgomp: present clause: not present on the device \\\(0x\[0-9a-f\]+, \[0-9\]+\\\)" } + ! { dg-output "libgomp: present clause: not present on the device \\\(0x\[0-9a-f\]+, \[0-9\]+\\\)" { target offload_device_nonshared_as } } + ! { dg-shouldfail "present error triggered" { offload_device_nonshared_as } } !$omp target update to (present: b) !$omp target exit data map (from: c) end program