From patchwork Thu Apr 19 09:06:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 900711 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-476607-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="nqatF5jw"; 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 40RY5L6085z9s2B for ; Thu, 19 Apr 2018 19:06:45 +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:in-reply-to:references:date:message-id :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=j/en0R2GTMvtYe47fQfXjt986To+DcwfnefHFaM0ZcFubsrp//9KM Z/gMYuFRmBMpJzJ5qlje9POJCWu91IFI0VlqQw/E5Uhxjg/ZOsoSHFi9ZDqdsKkD Aqg/GmT7qKRmZPYLm1mmpc0RWPNbKlgleFTarLfuk+/+DJdTqIOXmI= 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:in-reply-to:references:date:message-id :mime-version:content-type:content-transfer-encoding; s=default; bh=lfjRrrceWfL+OUFEaTlhI1+z3Rc=; b=nqatF5jwiEmxOr5MmII7jjaZ9nQ8 TXgiyc0Y0B3t3tOvChDs2xKzdwdOwq8M+WU4Mn6zBODFKmn4GcShBGV5OXsKlyTQ 4Qyof7Mq2YkFobEFnMtHCG5M80yrhc/lZPheKMRECShyY1v20rJZbhJVazZB6Caj x2ubqDopca9pRhQ= Received: (qmail 90886 invoked by alias); 19 Apr 2018 09:06:37 -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 90859 invoked by uid 89); 19 Apr 2018 09:06:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: =?iso-8859-1?q?No=2C_score=3D-24=2E9_required=3D5=2E?= =?iso-8859-1?q?0_tests=3DAWL=2CBAYES_00=2CGIT_PATCH_0=2CGIT_PATCH_?= =?iso-8859-1?q?1=2CGIT_PATCH_2=2CGIT_PATCH_3=2CRCVD_IN_DNSWL_NONE?= =?iso-8859-1?q?=2CSPF_PASS=2CURIBL_RED_autolearn=3Dham_version=3D3?= =?iso-8859-1?q?=2E3=2E2_spammy=3Dpromptly=2C_gr=2C_PROGRAM=2C_gr?= =?iso-8859-1?q?=C3=BC=C3?= X-Spam-User: qpsmtpd, 3 recipients X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 19 Apr 2018 09:06:33 +0000 Received: from svr-orw-fem-04.mgc.mentorg.com ([147.34.97.41]) by relay1.mentorg.com with esmtps (TLSv1:ECDHE-RSA-AES256-SHA:256) id 1f95WQ-0002ce-Uq from Thomas_Schwinge@mentor.com ; Thu, 19 Apr 2018 02:06:30 -0700 Received: from tftp-cs (147.34.91.1) by svr-orw-fem-04.mgc.mentorg.com (147.34.97.41) with Microsoft SMTP Server id 14.3.224.2; Thu, 19 Apr 2018 02:06:30 -0700 Received: by tftp-cs (Postfix, from userid 49978) id 0DA2DC229E; Thu, 19 Apr 2018 02:06:30 -0700 (PDT) From: Thomas Schwinge To: Thomas =?utf-8?b?S8O2bmln?= , "fortran@gcc.gnu.org" , gcc-patches CC: Subject: PR85463 '[nvptx] "exit" in offloaded region doesn't terminate process' (was: [patch, libfortran, committed] Implement stop_numeric for minimal targets) In-Reply-To: <751060e1-67cb-d290-4fd1-46b15b77fc1a@tkoenig.net> References: <751060e1-67cb-d290-4fd1-46b15b77fc1a@tkoenig.net> User-Agent: Notmuch/0.9-125-g4686d11 (http://notmuchmail.org) Emacs/25.2.2 (x86_64-pc-linux-gnu) Date: Thu, 19 Apr 2018 11:06:18 +0200 Message-ID: <87in8nsgz9.fsf@euler.schwinge.homeip.net> MIME-Version: 1.0 Hi! On Wed, 4 Apr 2018 11:30:34 +0200, Thomas König wrote: > the recent patch to make the gfortran and libgomp testsuites more > standard conforming, by replacing CALL ABORT() with STOP N, led > to numerous testsuite failures on nvptx because stop_numeric > was not implemented in minimal.c. > > I have committed the patch below in r259072 as obvious after Tom > de Vries had confirmed that it solves the problem. ... for some meaning of "solves the problem"; see below. ;-) Which you couldn't know, of course. (So, definitely thanks anyway, for promptly addressing the issue raised!) > --- runtime/minimal.c (Revision 259055) > +++ runtime/minimal.c (Arbeitskopie) > +void > +stop_numeric (int code, bool quiet) > +{ > + if (!quiet) > + printf ("STOP %d\n", code); > + > + exit (code); > +} Per PR85463 '[nvptx] "exit" in offloaded region doesn't terminate process' that I just filed, we currently have to use "abort" instead of "exit" for nvptx offloading, so I have applied the following in trunk r259491, where I completed this by adding and testing stop_string, error_stop_string, and error_stop_numeric functions, too. commit 6bc09e4fa2e5e59dee18f1c03f2d6529b9b0045b Author: tschwinge Date: Thu Apr 19 08:53:38 2018 +0000 PR85463 '[nvptx] "exit" in offloaded region doesn't terminate process' libgomp/ PR libfortran/85166 * testsuite/libgomp.oacc-fortran/abort-1.f90: Switch back to "call abort". * testsuite/libgomp.oacc-fortran/abort-2.f90: Likewise. libgfortran/ PR libfortran/85166 PR libgomp/85463 * runtime/minimal.c (stop_numeric): Reimplement. (stop_string, error_stop_string, error_stop_numeric): New functions. libgomp/ PR libgomp/85463 * testsuite/libgomp.oacc-fortran/error_stop-1.f: New file. * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@259491 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgfortran/ChangeLog | 8 +++ libgfortran/runtime/minimal.c | 80 +++++++++++++++++++++- libgomp/ChangeLog | 15 ++++ libgomp/testsuite/libgomp.oacc-fortran/abort-1.f90 | 5 +- libgomp/testsuite/libgomp.oacc-fortran/abort-2.f90 | 5 +- .../testsuite/libgomp.oacc-fortran/error_stop-1.f | 20 ++++++ .../testsuite/libgomp.oacc-fortran/error_stop-2.f | 20 ++++++ .../testsuite/libgomp.oacc-fortran/error_stop-3.f | 20 ++++++ libgomp/testsuite/libgomp.oacc-fortran/stop-1.f | 22 ++++++ libgomp/testsuite/libgomp.oacc-fortran/stop-2.f | 20 ++++++ libgomp/testsuite/libgomp.oacc-fortran/stop-3.f | 23 +++++++ 11 files changed, 234 insertions(+), 4 deletions(-) Grüße Thomas diff --git libgfortran/ChangeLog libgfortran/ChangeLog index d4a1fbb..ea4358c 100644 --- libgfortran/ChangeLog +++ libgfortran/ChangeLog @@ -1,3 +1,11 @@ +2018-04-19 Thomas Schwinge + + PR libfortran/85166 + PR libgomp/85463 + * runtime/minimal.c (stop_numeric): Reimplement. + (stop_string, error_stop_string, error_stop_numeric): New + functions. + 2018-04-19 Jakub Jelinek * configure: Regenerated. diff --git libgfortran/runtime/minimal.c libgfortran/runtime/minimal.c index e17666b..0b1efeb 100644 --- libgfortran/runtime/minimal.c +++ libgfortran/runtime/minimal.c @@ -188,6 +188,22 @@ sys_abort (void) abort(); } + +/* runtime/stop.c */ + +#undef report_exception +#define report_exception() do {} while (0) +#undef st_printf +#define st_printf printf +#undef estr_write +#define estr_write printf +/* Map "exit" to "abort"; see PR85463 '[nvptx] "exit" in offloaded region + doesn't terminate process'. */ +#undef exit +#define exit(...) do { abort (); } while (0) +#undef exit_error +#define exit_error(...) do { abort (); } while (0) + /* A numeric STOP statement. */ extern _Noreturn void stop_numeric (int, bool); @@ -197,7 +213,67 @@ void stop_numeric (int code, bool quiet) { if (!quiet) - printf ("STOP %d\n", code); - + { + report_exception (); + st_printf ("STOP %d\n", code); + } exit (code); } + + +/* A character string or blank STOP statement. */ + +void +stop_string (const char *string, size_t len, bool quiet) +{ + if (!quiet) + { + report_exception (); + if (string) + { + estr_write ("STOP "); + (void) write (STDERR_FILENO, string, len); + estr_write ("\n"); + } + } + exit (0); +} + + +/* Per Fortran 2008, section 8.4: "Execution of a STOP statement initiates + normal termination of execution. Execution of an ERROR STOP statement + initiates error termination of execution." Thus, error_stop_string returns + a nonzero exit status code. */ + +extern _Noreturn void error_stop_string (const char *, size_t, bool); +export_proto(error_stop_string); + +void +error_stop_string (const char *string, size_t len, bool quiet) +{ + if (!quiet) + { + report_exception (); + estr_write ("ERROR STOP "); + (void) write (STDERR_FILENO, string, len); + estr_write ("\n"); + } + exit_error (1); +} + + +/* A numeric ERROR STOP statement. */ + +extern _Noreturn void error_stop_numeric (int, bool); +export_proto(error_stop_numeric); + +void +error_stop_numeric (int code, bool quiet) +{ + if (!quiet) + { + report_exception (); + st_printf ("ERROR STOP %d\n", code); + } + exit_error (code); +} diff --git libgomp/ChangeLog libgomp/ChangeLog index 1025acb..f68a4a8 100644 --- libgomp/ChangeLog +++ libgomp/ChangeLog @@ -1,3 +1,18 @@ +2018-04-19 Thomas Schwinge + + PR libgomp/85463 + * testsuite/libgomp.oacc-fortran/error_stop-1.f: New file. + * 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. + + PR libfortran/85166 + * testsuite/libgomp.oacc-fortran/abort-1.f90: Switch back to "call + abort". + * testsuite/libgomp.oacc-fortran/abort-2.f90: Likewise. + 2018-04-19 Jakub Jelinek * configure: Regenerated. diff --git libgomp/testsuite/libgomp.oacc-fortran/abort-1.f90 libgomp/testsuite/libgomp.oacc-fortran/abort-1.f90 index dde3512..fc0af7f 100644 --- libgomp/testsuite/libgomp.oacc-fortran/abort-1.f90 +++ libgomp/testsuite/libgomp.oacc-fortran/abort-1.f90 @@ -1,9 +1,12 @@ +! Verify that an unconditional "call abort" inside an OpenACC parallel region +! does the right thing. + program main implicit none print *, "CheCKpOInT" !$acc parallel - STOP 1 + call abort !$acc end parallel end program main diff --git libgomp/testsuite/libgomp.oacc-fortran/abort-2.f90 libgomp/testsuite/libgomp.oacc-fortran/abort-2.f90 index 68d90e9..97a692b 100644 --- libgomp/testsuite/libgomp.oacc-fortran/abort-2.f90 +++ libgomp/testsuite/libgomp.oacc-fortran/abort-2.f90 @@ -1,3 +1,6 @@ +! Verify that a conditional "call abort" inside an OpenACC parallel region does +! the right thing. + program main implicit none @@ -6,7 +9,7 @@ program main !$acc parallel copyin(argc) if (argc .ne. 0) then - STOP 1 + call abort end if !$acc end parallel diff --git libgomp/testsuite/libgomp.oacc-fortran/error_stop-1.f libgomp/testsuite/libgomp.oacc-fortran/error_stop-1.f new file mode 100644 index 0000000..4965e67 --- /dev/null +++ libgomp/testsuite/libgomp.oacc-fortran/error_stop-1.f @@ -0,0 +1,20 @@ +! { dg-do run } + + PROGRAM MAIN + IMPLICIT NONE + + PRINT *, "CheCKpOInT" +!$ACC PARALLEL + ERROR STOP +!$ACC END PARALLEL + PRINT *, "WrONg WAy" + + END PROGRAM MAIN + +! { dg-output "CheCKpOInT(\n|\r\n|\r)+" } +! { dg-output "ERROR STOP (\n|\r\n|\r)+" } +! PR85463. The "minimal" libgfortran implementation used with nvptx +! offloading is a little bit different. +! { dg-output "Error termination.*" { target { ! openacc_nvidia_accel_selected } } } +! { dg-output "libgomp: cuStreamSynchronize error.*" { target openacc_nvidia_accel_selected } } +! { dg-shouldfail "" } diff --git libgomp/testsuite/libgomp.oacc-fortran/error_stop-2.f libgomp/testsuite/libgomp.oacc-fortran/error_stop-2.f new file mode 100644 index 0000000..7103fdb --- /dev/null +++ libgomp/testsuite/libgomp.oacc-fortran/error_stop-2.f @@ -0,0 +1,20 @@ +! { dg-do run } + + PROGRAM MAIN + IMPLICIT NONE + + PRINT *, "CheCKpOInT" +!$ACC PARALLEL + ERROR STOP 35 +!$ACC END PARALLEL + PRINT *, "WrONg WAy" + + END PROGRAM MAIN + +! { dg-output "CheCKpOInT(\n|\r\n|\r)+" } +! { dg-output "ERROR STOP 35(\n|\r\n|\r)+" } +! PR85463. The "minimal" libgfortran implementation used with nvptx +! offloading is a little bit different. +! { dg-output "Error termination.*" { target { ! openacc_nvidia_accel_selected } } } +! { dg-output "libgomp: cuStreamSynchronize error.*" { target openacc_nvidia_accel_selected } } +! { dg-shouldfail "" } diff --git libgomp/testsuite/libgomp.oacc-fortran/error_stop-3.f libgomp/testsuite/libgomp.oacc-fortran/error_stop-3.f new file mode 100644 index 0000000..9c217f1 --- /dev/null +++ libgomp/testsuite/libgomp.oacc-fortran/error_stop-3.f @@ -0,0 +1,20 @@ +! { dg-do run } + + PROGRAM MAIN + IMPLICIT NONE + + PRINT *, "CheCKpOInT" +!$ACC PARALLEL + ERROR STOP "SiGN" +!$ACC END PARALLEL + PRINT *, "WrONg WAy" + + END PROGRAM MAIN + +! { dg-output "CheCKpOInT(\n|\r\n|\r)+" } +! { dg-output "ERROR STOP SiGN(\n|\r\n|\r)+" } +! PR85463. The "minimal" libgfortran implementation used with nvptx +! offloading is a little bit different. +! { dg-output "Error termination.*" { target { ! openacc_nvidia_accel_selected } } } +! { dg-output "libgomp: cuStreamSynchronize error.*" { target openacc_nvidia_accel_selected } } +! { dg-shouldfail "" } diff --git libgomp/testsuite/libgomp.oacc-fortran/stop-1.f libgomp/testsuite/libgomp.oacc-fortran/stop-1.f new file mode 100644 index 0000000..af267fc --- /dev/null +++ libgomp/testsuite/libgomp.oacc-fortran/stop-1.f @@ -0,0 +1,22 @@ +! { dg-do run } + + PROGRAM MAIN + IMPLICIT NONE + + PRINT *, "CheCKpOInT" +!$ACC PARALLEL + STOP +!$ACC END PARALLEL + PRINT *, "WrONg WAy" + + END PROGRAM MAIN + +! { dg-output "CheCKpOInT(\n|\r\n|\r)+" } +! PR85463. The "minimal" libgfortran 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 } } diff --git libgomp/testsuite/libgomp.oacc-fortran/stop-2.f libgomp/testsuite/libgomp.oacc-fortran/stop-2.f new file mode 100644 index 0000000..13c0684 --- /dev/null +++ libgomp/testsuite/libgomp.oacc-fortran/stop-2.f @@ -0,0 +1,20 @@ +! { dg-do run } + + PROGRAM MAIN + IMPLICIT NONE + + PRINT *, "CheCKpOInT" +!$ACC PARALLEL + STOP 35 +!$ACC END PARALLEL + PRINT *, "WrONg WAy" + + 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 +! offloading is a little bit different. +! { dg-output "libgomp: cuStreamSynchronize error.*" { target openacc_nvidia_accel_selected } } +! { dg-output "$" } +! { dg-shouldfail "" } diff --git libgomp/testsuite/libgomp.oacc-fortran/stop-3.f libgomp/testsuite/libgomp.oacc-fortran/stop-3.f new file mode 100644 index 0000000..3bd7446 --- /dev/null +++ libgomp/testsuite/libgomp.oacc-fortran/stop-3.f @@ -0,0 +1,23 @@ +! { dg-do run } + + PROGRAM MAIN + IMPLICIT NONE + + PRINT *, "CheCKpOInT" +!$ACC PARALLEL + STOP "SiGN" +!$ACC END PARALLEL + PRINT *, "WrONg WAy" + + 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 +! 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 } }