From patchwork Fri Jan 20 20:12:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 46617 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp404358wrn; Fri, 20 Jan 2023 12:12:51 -0800 (PST) X-Google-Smtp-Source: AMrXdXuKJ+cwwgdW8+EgJSgwB3ahC+kLuBf2OE8yq4UYwTm+vX2eDSUAGHGPeZcjWQ8l4puT+Emp X-Received: by 2002:a17:906:37ca:b0:871:14fc:a299 with SMTP id o10-20020a17090637ca00b0087114fca299mr18957579ejc.1.1674245571432; Fri, 20 Jan 2023 12:12:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674245571; cv=none; d=google.com; s=arc-20160816; b=u605hktkfLPI4xqvXUlqkmnr8Ewa2hQ08K9U1C7FfeffsDf2Li6Q4ZrlbMQLUJKP7Q DcjKKGLMFD8xs3gvxXo/lD69nmYbQgwEFwbl19LRn22KQ6dkRGd57C0qqerXTI0jLLGY 95NAXKzyl6uE+4jmFHpzZrU0HM2CwLxobPtO7873U1FzF6PbEOL2NnsYTUoG7Gv+UFw7 C39rJg+pSoe7IACTuhJyQZR1X3imvhOOY7AMz9mLOzh/1YzVcMm0U9Ij1O/a6lhGvugU MUgPBkn4JVb1WMltXkxMe18Mhno3DlwttzxjsydFGRGevitvl6ClFyXrcchg9FlVJVQG nUtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:message-id:date :user-agent:references:in-reply-to:subject:cc:to:from:ironport-sdr :dmarc-filter:delivered-to; bh=4JH26u1hn3jieZ6fsG3Ee/WTSH+3aKQlg2hpF4PRfoc=; b=B25XAqDtO7Q+oF0kSEVurMZPficgNtD2xY+DEgMJUDYY58sXA0u9LW93LFBODmuZW6 NclzxCCWbbwoxYSrhmqZPenDT8V5cVi+rOtEn/6JD+H/sDoD0NpClZm7hUqPp7LYcwf2 bkEKq5UrhqElfjydLynrXK5UWf7hluQUjbtFW/XSUNxbqmyVskI4oUGHdxEVHWwcl9YM tRBcRBuoVzUHnViTGi/PUSv840pOmxQ4T3B2D8uG/vS38Z5RmS48sTahXs9KgqwZDsTp WaVAF6nLDZm2GwP0YObMlkNZpWu+U7IHsJG8U+5yGyPjnw/CL6vgQq2+MN5OMH/d/Nsd LNHA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id nc42-20020a1709071c2a00b008776988fa30si8558878ejc.144.2023.01.20.12.12.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jan 2023 12:12:51 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9F65D38582AB for ; Fri, 20 Jan 2023 20:12:44 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id 02F2A3858D20; Fri, 20 Jan 2023 20:12:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 02F2A3858D20 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="5.97,233,1669104000"; d="scan'208,223";a="95182249" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 20 Jan 2023 12:12:15 -0800 IronPort-SDR: MdfcPMPFKNbsbftBIrevfi0PWW1jNvQViGfRcMDuVo3DjNtVldv7JonDumQapgy1FlRR2ljE09 +IGCo1uLz/OP5nFwoonmAnTx9n99rbEpfPM7JfOEWcItkFkBs5mc6rfXODkenGNvPRbFJ8XKjv gEl5iwu6B8UxmNiULXAu+ougA1wcvYhRM+nRVdY3fA1wHpPhC8B1GRoW3O/qcM+2zLEdBMm/Ca x4rsp8WZoUsqr4y4hjn8ZjJ/VgKlpbYIZJD9bypMJOlKN4lMWKbyb3McyXv2CqfG7O8F2mZiv4 cbY= From: Thomas Schwinge To: CC: , Tom de Vries , Jakub Jelinek Subject: Clean up after newlib "nvptx: In offloading execution, map '_exit' to 'abort' [GCC PR85463]" In-Reply-To: <20230119220005.2002779-1-thomas@codesourcery.com> References: <87in8nsgz9.fsf@euler.schwinge.homeip.net> <20230119220005.2002779-1-thomas@codesourcery.com> User-Agent: Notmuch/0.29.3+94~g74c3f1b (https://notmuchmail.org) Emacs/28.2 (x86_64-pc-linux-gnu) Date: Fri, 20 Jan 2023 21:12:05 +0100 Message-ID: <87lelxotii.fsf@euler.schwinge.homeip.net> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-13.mgc.mentorg.com (139.181.222.13) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755573724148181720?= X-GMAIL-MSGID: =?utf-8?q?1755573724148181720?= Hi! Re the newlib commit 05a2d7a8b3277b469e7cb121115bba398adc8559 "nvptx: In offloading execution, map '_exit' to 'abort' [GCC PR85463]" that I've just pushes to newlib main branch: On 2023-01-19T23:00:05+0100, I wrote: > This is still not properly resolving > '[nvptx] "exit" in offloaded region doesn't terminate process', but is > one step into that direction, and allows for simplifying some GCC code. > --- a/newlib/libc/machine/nvptx/_exit.c > +++ b/newlib/libc/machine/nvptx/_exit.c > @@ -26,7 +27,15 @@ void __attribute__((noreturn)) > _exit (int status) > { > if (__exitval_ptr) > - *__exitval_ptr = status; > - for (;;) > - asm ("exit;" ::: "memory"); > + { > + *__exitval_ptr = status; > + for (;;) > + asm ("exit;" ::: "memory"); > + } > + else /* offloading */ > + { > + /* Map to 'abort'; see > + '[nvptx] "exit" in offloaded region doesn't terminate process'. */ > + abort (); > + } > } That has put "the PR85463 stuff" into the one central place, and allows for simplifying GCC as per the attached 'Clean up after newlib "nvptx: In offloading execution, map '_exit' to 'abort' [GCC PR85463]"', which I've just pushed to GCC devel/omp/gcc-12 branch in commit 094b379f461bb4b635327cde26eabc0966159fec, and intend to push to GCC master branch once the latter depends on updated newlib for other (functional) reasons. Grüße Thomas ----------------- 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 From 094b379f461bb4b635327cde26eabc0966159fec Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Thu, 19 Jan 2023 20:25:45 +0100 Subject: [PATCH] Clean up after newlib "nvptx: In offloading execution, map '_exit' to 'abort' [GCC PR85463]" PR target/85463 libgfortran/ * runtime/minimal.c [__nvptx__] (exit): Don't override. libgomp/ * config/nvptx/error.c (exit): Don't override. * testsuite/libgomp.oacc-fortran/error_stop-1.f: Update. * testsuite/libgomp.oacc-fortran/error_stop-2.f: Likewise. * testsuite/libgomp.oacc-fortran/error_stop-3.f: Likewise. * testsuite/libgomp.oacc-fortran/stop-1.f: Likewise. * testsuite/libgomp.oacc-fortran/stop-2.f: Likewise. * testsuite/libgomp.oacc-fortran/stop-3.f: Likewise. --- libgfortran/ChangeLog.omp | 4 ++++ libgfortran/runtime/minimal.c | 8 -------- libgomp/ChangeLog.omp | 9 +++++++++ libgomp/config/nvptx/error.c | 7 ------- .../testsuite/libgomp.oacc-fortran/error_stop-1.f | 8 +++++--- .../testsuite/libgomp.oacc-fortran/error_stop-2.f | 8 +++++--- .../testsuite/libgomp.oacc-fortran/error_stop-3.f | 8 +++++--- libgomp/testsuite/libgomp.oacc-fortran/stop-1.f | 13 +++++++++---- libgomp/testsuite/libgomp.oacc-fortran/stop-2.f | 6 +++++- libgomp/testsuite/libgomp.oacc-fortran/stop-3.f | 12 ++++++++---- 10 files changed, 50 insertions(+), 33 deletions(-) create mode 100644 libgfortran/ChangeLog.omp diff --git a/libgfortran/ChangeLog.omp b/libgfortran/ChangeLog.omp new file mode 100644 index 00000000000..b08c264daf9 --- /dev/null +++ b/libgfortran/ChangeLog.omp @@ -0,0 +1,4 @@ +2023-01-20 Thomas Schwinge + + PR target/85463 + * runtime/minimal.c [__nvptx__] (exit): Don't override. diff --git a/libgfortran/runtime/minimal.c b/libgfortran/runtime/minimal.c index 326ff822ca7..5af2bada2f6 100644 --- a/libgfortran/runtime/minimal.c +++ b/libgfortran/runtime/minimal.c @@ -31,14 +31,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #endif -#if __nvptx__ -/* Map "exit" to "abort"; see PR85463 '[nvptx] "exit" in offloaded region - doesn't terminate process'. */ -# undef exit -# define exit(status) do { (void) (status); abort (); } while (0) -#endif - - #if __nvptx__ /* 'printf' is all we have. */ # undef estr_vprintf diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp index 134d450f44a..33aa4b01350 100644 --- a/libgomp/ChangeLog.omp +++ b/libgomp/ChangeLog.omp @@ -1,5 +1,14 @@ 2023-01-20 Thomas Schwinge + PR target/85463 + * config/nvptx/error.c (exit): Don't override. + * testsuite/libgomp.oacc-fortran/error_stop-1.f: Update. + * testsuite/libgomp.oacc-fortran/error_stop-2.f: Likewise. + * testsuite/libgomp.oacc-fortran/error_stop-3.f: Likewise. + * testsuite/libgomp.oacc-fortran/stop-1.f: Likewise. + * testsuite/libgomp.oacc-fortran/stop-2.f: Likewise. + * testsuite/libgomp.oacc-fortran/stop-3.f: Likewise. + * testsuite/libgomp.c/simd-math-1.c: Fix configuration, again. * testsuite/libgomp.oacc-c-c++-common/abort-3.c: Force diff --git a/libgomp/config/nvptx/error.c b/libgomp/config/nvptx/error.c index ab99130ed4a..1756eaeee53 100644 --- a/libgomp/config/nvptx/error.c +++ b/libgomp/config/nvptx/error.c @@ -58,11 +58,4 @@ #endif -/* The 'exit (EXIT_FAILURE);' of an Fortran (only, huh?) OpenMP 'error' - directive with 'severity (fatal)' causes a hang, so 'abort' instead of - 'exit'. */ -#undef exit -#define exit(status) abort () - - #include "../../error.c" diff --git a/libgomp/testsuite/libgomp.oacc-fortran/error_stop-1.f b/libgomp/testsuite/libgomp.oacc-fortran/error_stop-1.f index de727749a53..3918d6853f6 100644 --- a/libgomp/testsuite/libgomp.oacc-fortran/error_stop-1.f +++ b/libgomp/testsuite/libgomp.oacc-fortran/error_stop-1.f @@ -16,14 +16,16 @@ END PROGRAM MAIN ! { dg-output "CheCKpOInT(\n|\r\n|\r)+" } + ! { dg-output "ERROR STOP (\n|\r\n|\r)+" } ! ! In gfortran's main program, libfortran's set_options is called - which sets ! compiler_options.backtrace = 1 by default. For an offload libgfortran, this ! is never called and, hence, "Error termination." is never printed. Thus: ! { dg-output "Error termination.*" { target { ! { openacc_nvidia_accel_selected || openacc_radeon_accel_selected } } } } -! -! PR85463: + +! PR85463. The 'exit' implementation used with nvptx +! offloading is a little bit different. ! { dg-output "libgomp: cuStreamSynchronize error.*" { target openacc_nvidia_accel_selected } } -! + ! { dg-shouldfail "" } diff --git a/libgomp/testsuite/libgomp.oacc-fortran/error_stop-2.f b/libgomp/testsuite/libgomp.oacc-fortran/error_stop-2.f index 475c9cb5850..5951e8cbe64 100644 --- a/libgomp/testsuite/libgomp.oacc-fortran/error_stop-2.f +++ b/libgomp/testsuite/libgomp.oacc-fortran/error_stop-2.f @@ -16,14 +16,16 @@ END PROGRAM MAIN ! { dg-output "CheCKpOInT(\n|\r\n|\r)+" } + ! { dg-output "ERROR STOP 35(\n|\r\n|\r)+" } ! ! In gfortran's main program, libfortran's set_options is called - which sets ! compiler_options.backtrace = 1 by default. For an offload libgfortran, this ! is never called and, hence, "Error termination." is never printed. Thus: ! { dg-output "Error termination.*" { target { ! { openacc_nvidia_accel_selected || openacc_radeon_accel_selected } } } } -! -! PR85463: + +! PR85463. The 'exit' implementation used with nvptx +! offloading is a little bit different. ! { dg-output "libgomp: cuStreamSynchronize error.*" { target openacc_nvidia_accel_selected } } -! + ! { dg-shouldfail "" } diff --git a/libgomp/testsuite/libgomp.oacc-fortran/error_stop-3.f b/libgomp/testsuite/libgomp.oacc-fortran/error_stop-3.f index ab63444ce34..15e02d8b744 100644 --- a/libgomp/testsuite/libgomp.oacc-fortran/error_stop-3.f +++ b/libgomp/testsuite/libgomp.oacc-fortran/error_stop-3.f @@ -16,14 +16,16 @@ END PROGRAM MAIN ! { dg-output "CheCKpOInT(\n|\r\n|\r)+" } + ! { dg-output "ERROR STOP SiGN(\n|\r\n|\r)+" } ! ! In gfortran's main program, libfortran's set_options is called - which sets ! compiler_options.backtrace = 1 by default. For an offload libgfortran, this ! is never called and, hence, "Error termination." is never printed. Thus: ! { dg-output "Error termination.*" { target { ! { openacc_nvidia_accel_selected || openacc_radeon_accel_selected } } } } -! -! PR85463: + +! PR85463. The 'exit' implementation used with nvptx +! offloading is a little bit different. ! { dg-output "libgomp: cuStreamSynchronize error.*" { target openacc_nvidia_accel_selected } } -! + ! { dg-shouldfail "" } diff --git a/libgomp/testsuite/libgomp.oacc-fortran/stop-1.f b/libgomp/testsuite/libgomp.oacc-fortran/stop-1.f index 2c00d2e5bf8..590b3c97da4 100644 --- a/libgomp/testsuite/libgomp.oacc-fortran/stop-1.f +++ b/libgomp/testsuite/libgomp.oacc-fortran/stop-1.f @@ -16,11 +16,16 @@ END PROGRAM MAIN ! { dg-output "CheCKpOInT(\n|\r\n|\r)+" } -! PR85463. The "minimal" libgfortran implementation used with nvptx + +! { dg-output "" } +! +! PR85463. The 'exit' implementation used with nvptx ! offloading is a little bit different. ! { dg-output "libgomp: cuStreamSynchronize error.*" { target openacc_nvidia_accel_selected } } + ! { dg-output "$" } + ! PR85463. STOP with code zero (as implied here) should actually -! terminate the process normally, but doesn't in the "minimal" -! libgfortran implementation used with nvptx offloading. -! { dg-shouldfail "" { openacc_nvidia_accel_selected } } +! terminate the process normally, but doesn't with the 'exit' +! implementation used with nvptx offloading. +! { dg-shouldfail PR85463 { openacc_nvidia_accel_selected } } diff --git a/libgomp/testsuite/libgomp.oacc-fortran/stop-2.f b/libgomp/testsuite/libgomp.oacc-fortran/stop-2.f index adade54557c..fe7ee37813a 100644 --- a/libgomp/testsuite/libgomp.oacc-fortran/stop-2.f +++ b/libgomp/testsuite/libgomp.oacc-fortran/stop-2.f @@ -16,9 +16,13 @@ END PROGRAM MAIN ! { dg-output "CheCKpOInT(\n|\r\n|\r)+" } + ! { dg-output "STOP 35(\n|\r\n|\r)+" } -! PR85463. The "minimal" libgfortran implementation used with nvptx +! +! PR85463. The 'exit' implementation used with nvptx ! offloading is a little bit different. ! { dg-output "libgomp: cuStreamSynchronize error.*" { target openacc_nvidia_accel_selected } } + ! { dg-output "$" } + ! { dg-shouldfail "" } diff --git a/libgomp/testsuite/libgomp.oacc-fortran/stop-3.f b/libgomp/testsuite/libgomp.oacc-fortran/stop-3.f index 157e369d4e7..b28989895b5 100644 --- a/libgomp/testsuite/libgomp.oacc-fortran/stop-3.f +++ b/libgomp/testsuite/libgomp.oacc-fortran/stop-3.f @@ -16,12 +16,16 @@ END PROGRAM MAIN ! { dg-output "CheCKpOInT(\n|\r\n|\r)+" } + ! { dg-output "STOP SiGN(\n|\r\n|\r)+" } -! PR85463. The "minimal" libgfortran implementation used with nvptx +! +! PR85463. The 'exit' implementation used with nvptx ! offloading is a little bit different. ! { dg-output "libgomp: cuStreamSynchronize error.*" { target openacc_nvidia_accel_selected } } + ! { dg-output "$" } + ! PR85463. STOP with code zero (as implied here) should actually -! terminate the process normally, but doesn't in the "minimal" -! libgfortran implementation used with nvptx offloading. -! { dg-shouldfail "" { openacc_nvidia_accel_selected } } +! terminate the process normally, but doesn't with the 'exit' +! implementation used with nvptx offloading. +! { dg-shouldfail PR85463 { openacc_nvidia_accel_selected } } -- 2.25.1