From patchwork Tue Jan 24 09:37:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 63614 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 80DDF3858438 for ; Tue, 24 Jan 2023 09:37:39 +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 04DB13858C30; Tue, 24 Jan 2023 09:37:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 04DB13858C30 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,242,1669104000"; d="scan'208,223";a="94398574" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa3.mentor.iphmx.com with ESMTP; 24 Jan 2023 01:37:09 -0800 IronPort-SDR: wGbbSwJKmiRSJUn5M0LfPkkQ0useuKx4eo2Y0znSotyfvTTNn0WtaYTIBj3xRT0MQMYTNo/NoY pp8JGVhGQrWZruGJybZTZ1Vtj1hvVarQE1OFmyMe9AuJhQB5UhzKMc636qYa2TTNX5uH14eI3m VqEBWA5jjEOJteySM33HESyy+jAdx5X9ZlfwGWaa4S/bW2YLgd3hfDhMid/4AHAuULZ+0X+Ty5 K9xdQPon7J1STgwjmd6+YvE9zDCsukpIyTwHFPr2+9Gd3OKMvADKyANoqhy8mzQr+pfR9muGz6 ELk= From: Thomas Schwinge To: CC: , Tom de Vries , Andrew Stubbs , Tobias Burnus Subject: Update 'libgomp/libgomp.texi' for 'nvptx, libgfortran: Switch out of "minimal" mode' (was: nvptx, libgfortran: Switch out of "minimal" mode) In-Reply-To: <87mt6c29gv.fsf@dem-tschwing-1.ger.mentorg.com> References: <87pmb82a0t.fsf@dem-tschwing-1.ger.mentorg.com> <87mt6c29gv.fsf@dem-tschwing-1.ger.mentorg.com> User-Agent: Notmuch/0.29.1+93~g67ed7df (https://notmuchmail.org) Emacs/26.3 (x86_64-pc-linux-gnu) Date: Tue, 24 Jan 2023 10:37:00 +0100 Message-ID: <87bkmo1dfn.fsf@dem-tschwing-1.ger.mentorg.com> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) 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, 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi! On 2023-01-20T22:16:00+0100, I wrote: > On 2023-01-20T22:04:02+0100, I wrote: >> We've been (t)asked to enable (portions of) GCC/Fortran I/O for nvptx >> offloading, which means building a normal (non-'LIBGFOR_MINIMAL') >> configuration of libgfortran. > > This is achieved by 'nvptx, libgfortran: Switch out of "minimal" mode', > see attached, again based on WIP work by Andrew Stubbs. This I've just > pushed to devel/omp/gcc-12 branch in > commit c7734c6fbb5513b4da6306de7bc85de9b8547988, and would like to push > to master branch once other pending GCC patches have been accepted. > > > The OpenACC XFAILs: "[...] overflows the stack for nvptx offloading" > are unresolved at this point; see the discussion around > "Handling of large stack objects in GPU code generation -- maybe transform into heap allocation?", > and my "nvptx: '-mframe-malloc-threshold', '-Wframe-malloc-threshold'" > experimenting. (The latter works to some extent, but also has other > issues that I shall detail at some later point in time.) I had a note from Tobias to "update the the last but one bullet point at https://gcc.gnu.org/onlinedocs/libgomp/nvptx.html". Thus pushed to devel/omp/gcc-12 branch commit 8c29332e98ca4669a059ebc0d90903b409ae049f "Update 'libgomp/libgomp.texi' for 'nvptx, libgfortran: Switch out of "minimal" mode'", see attached. Please consider that one 'fixup'ed into the GCC master branch submission. Grüße Thomas > From c7734c6fbb5513b4da6306de7bc85de9b8547988 Mon Sep 17 00:00:00 2001 > From: Thomas Schwinge > Date: Wed, 21 Sep 2022 18:58:34 +0200 > Subject: [PATCH] nvptx, libgfortran: Switch out of "minimal" mode > > ..., in order to enable (portions of) Fortran I/O, for example. > > libgfortran/ChangeLog: > > * configure: Regenerate. > * configure.ac: No longer set LIBGFOR_MINIMAL for nvptx. > > libgomp/ChangeLog: > > * testsuite/libgomp.fortran/target-print-1.f90: Adjust. > * testsuite/libgomp.fortran/target-print-1-nvptx.f90: Remove. > * testsuite/libgomp.oacc-fortran/print-1.f90: Adjust. > * testsuite/libgomp.oacc-fortran/print-1-nvptx.f90: Remove. > * testsuite/libgomp.oacc-fortran/error_stop-2.f: Adjust. > * testsuite/libgomp.oacc-fortran/stop-2.f: Likewise. > > Co-authored-by: Andrew Stubbs > --- > libgfortran/ChangeLog.omp | 6 ++++++ > libgfortran/configure | 17 ++++++----------- > libgfortran/configure.ac | 17 ++++++----------- > libgomp/ChangeLog.omp | 7 +++++++ > .../libgomp.fortran/target-print-1-nvptx.f90 | 11 ----------- > .../libgomp.fortran/target-print-1.f90 | 3 --- > .../libgomp.oacc-fortran/error_stop-2.f | 4 +++- > .../libgomp.oacc-fortran/print-1-nvptx.f90 | 11 ----------- > .../testsuite/libgomp.oacc-fortran/print-1.f90 | 5 ++--- > libgomp/testsuite/libgomp.oacc-fortran/stop-2.f | 4 +++- > 10 files changed, 33 insertions(+), 52 deletions(-) > delete mode 100644 libgomp/testsuite/libgomp.fortran/target-print-1-nvptx.f90 > delete mode 100644 libgomp/testsuite/libgomp.oacc-fortran/print-1-nvptx.f90 > > diff --git a/libgfortran/ChangeLog.omp b/libgfortran/ChangeLog.omp > index b08c264daf9..925575e65fa 100644 > --- a/libgfortran/ChangeLog.omp > +++ b/libgfortran/ChangeLog.omp > @@ -1,3 +1,9 @@ > +2023-01-20 Thomas Schwinge > + Andrew Stubbs > + > + * configure: Regenerate. > + * configure.ac: No longer set LIBGFOR_MINIMAL for nvptx. > + > 2023-01-20 Thomas Schwinge > > PR target/85463 > diff --git a/libgfortran/configure b/libgfortran/configure > index ae64dca3114..3e5c931d4ad 100755 > --- a/libgfortran/configure > +++ b/libgfortran/configure > @@ -6230,17 +6230,12 @@ else > fi > > > -# For GPU offloading, not everything in libfortran can be supported. > -# Currently, the only target that has this problem is nvptx. The > -# following is a (partial) list of features that are unsupportable on > -# this particular target: > -# * Constructors > -# * alloca > -# * C library support for I/O, with printf as the one notable exception > -# * C library support for other features such as signal, environment > -# variables, time functions > - > - if test "x${target_cpu}" = xnvptx; then > +# "Minimal" mode is for targets that cannot (yet) support all features of > +# libgfortran. It avoids the need for working constructors, alloca, and C > +# library support for I/O, signals, environment variables, time functions, etc. > +# At present there are no targets that require this mode. > + > + if false; then > LIBGFOR_MINIMAL_TRUE= > LIBGFOR_MINIMAL_FALSE='#' > else > diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac > index 97cc490cb5e..e5552949cc6 100644 > --- a/libgfortran/configure.ac > +++ b/libgfortran/configure.ac > @@ -222,17 +222,12 @@ AM_CONDITIONAL(LIBGFOR_USE_SYMVER, [test "x$gfortran_use_symver" != xno]) > AM_CONDITIONAL(LIBGFOR_USE_SYMVER_GNU, [test "x$gfortran_use_symver" = xgnu]) > AM_CONDITIONAL(LIBGFOR_USE_SYMVER_SUN, [test "x$gfortran_use_symver" = xsun]) > > -# For GPU offloading, not everything in libfortran can be supported. > -# Currently, the only target that has this problem is nvptx. The > -# following is a (partial) list of features that are unsupportable on > -# this particular target: > -# * Constructors > -# * alloca > -# * C library support for I/O, with printf as the one notable exception > -# * C library support for other features such as signal, environment > -# variables, time functions > - > -AM_CONDITIONAL(LIBGFOR_MINIMAL, [test "x${target_cpu}" = xnvptx]) > +# "Minimal" mode is for targets that cannot (yet) support all features of > +# libgfortran. It avoids the need for working constructors, alloca, and C > +# library support for I/O, signals, environment variables, time functions, etc. > +# At present there are no targets that require this mode. > + > +AM_CONDITIONAL(LIBGFOR_MINIMAL, false) > > # Some compiler target support may have limited support for integer > # or floating point numbers – or may want to reduce the libgfortran size > diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp > index 32aa9705296..30b1e558ea3 100644 > --- a/libgomp/ChangeLog.omp > +++ b/libgomp/ChangeLog.omp > @@ -1,5 +1,12 @@ > 2023-01-20 Thomas Schwinge > > + * testsuite/libgomp.fortran/target-print-1.f90: Adjust. > + * testsuite/libgomp.fortran/target-print-1-nvptx.f90: Remove. > + * testsuite/libgomp.oacc-fortran/print-1.f90: Adjust. > + * testsuite/libgomp.oacc-fortran/print-1-nvptx.f90: Remove. > + * testsuite/libgomp.oacc-fortran/error_stop-2.f: Adjust. > + * testsuite/libgomp.oacc-fortran/stop-2.f: Likewise. > + > * plugin/plugin-nvptx.c (nvptx_do_global_cdtors): New. > (nvptx_close_device, GOMP_OFFLOAD_load_image) > (GOMP_OFFLOAD_unload_image): Call it. > diff --git a/libgomp/testsuite/libgomp.fortran/target-print-1-nvptx.f90 b/libgomp/testsuite/libgomp.fortran/target-print-1-nvptx.f90 > deleted file mode 100644 > index a89c9c33484..00000000000 > --- a/libgomp/testsuite/libgomp.fortran/target-print-1-nvptx.f90 > +++ /dev/null > @@ -1,11 +0,0 @@ > -! Ensure that write on the offload device works, nvptx offloading variant. > - > -! This doesn't compile: for nvptx offloading we're using a minimal libgfortran > -! configuration. > -! { dg-do link } ! ..., but still apply 'dg-do run' options. > -! { dg-xfail-if "minimal libgfortran" { offload_target_nvptx } } > - > -! Skip duplicated testing. > -! { dg-skip-if "separate file" { ! offload_target_nvptx } } > - > -include 'target-print-1.f90' > diff --git a/libgomp/testsuite/libgomp.fortran/target-print-1.f90 b/libgomp/testsuite/libgomp.fortran/target-print-1.f90 > index 327bb22cb6d..9ac70e5a85f 100644 > --- a/libgomp/testsuite/libgomp.fortran/target-print-1.f90 > +++ b/libgomp/testsuite/libgomp.fortran/target-print-1.f90 > @@ -3,9 +3,6 @@ > ! { dg-do run } > ! { dg-output "The answer is 42(\n|\r\n|\r)+" } > > -! Separate file 'target-print-1-nvptx.f90' for nvptx offloading. > -! { dg-skip-if "separate file" { offload_target_nvptx } } > - > program main > implicit none > integer :: var = 42 > diff --git a/libgomp/testsuite/libgomp.oacc-fortran/error_stop-2.f b/libgomp/testsuite/libgomp.oacc-fortran/error_stop-2.f > index 5951e8cbe64..bbb4b55ef2c 100644 > --- a/libgomp/testsuite/libgomp.oacc-fortran/error_stop-2.f > +++ b/libgomp/testsuite/libgomp.oacc-fortran/error_stop-2.f > @@ -17,7 +17,9 @@ > > ! { dg-output "CheCKpOInT(\n|\r\n|\r)+" } > > -! { dg-output "ERROR STOP 35(\n|\r\n|\r)+" } > +! '_gfortran_error_stop_numeric' -> '_gfortrani_st_printf' -> [...] > +! overflows the stack for nvptx offloading, thus XFAILed. > +! { dg-output "ERROR STOP 35(\n|\r\n|\r)+" { xfail openacc_nvidia_accel_selected } } > ! > ! In gfortran's main program, libfortran's set_options is called - which sets > ! compiler_options.backtrace = 1 by default. For an offload libgfortran, this > diff --git a/libgomp/testsuite/libgomp.oacc-fortran/print-1-nvptx.f90 b/libgomp/testsuite/libgomp.oacc-fortran/print-1-nvptx.f90 > deleted file mode 100644 > index 866c8654355..00000000000 > --- a/libgomp/testsuite/libgomp.oacc-fortran/print-1-nvptx.f90 > +++ /dev/null > @@ -1,11 +0,0 @@ > -! Ensure that write on the offload device works, nvptx offloading variant. > - > -! This doesn't compile: for nvptx offloading we're using a minimal libgfortran > -! configuration. > -! { dg-do link } ! ..., but still apply 'dg-do run' options. > -! { dg-xfail-if "minimal libgfortran" { offload_target_nvptx } } > - > -! Skip duplicated testing. > -! { dg-skip-if "separate file" { ! offload_target_nvptx } } > - > -include 'print-1.f90' > diff --git a/libgomp/testsuite/libgomp.oacc-fortran/print-1.f90 b/libgomp/testsuite/libgomp.oacc-fortran/print-1.f90 > index d2f89d915f8..d04503a0249 100644 > --- a/libgomp/testsuite/libgomp.oacc-fortran/print-1.f90 > +++ b/libgomp/testsuite/libgomp.oacc-fortran/print-1.f90 > @@ -2,9 +2,8 @@ > > ! { dg-do run } > ! { dg-output "The answer is 42(\n|\r\n|\r)+" } > - > -! Separate file 'print-1-nvptx.f90' for nvptx offloading. > -! { dg-skip-if "separate file" { offload_target_nvptx } } > +! The 'write' overflows the stack for nvptx offloading, thus XFAILed. > +! { dg-xfail-run-if TODO { openacc_nvidia_accel_selected } } > > ! { dg-additional-options "-fopt-info-note-omp" } > ! { dg-additional-options "-foffload=-fopt-info-note-omp" } > diff --git a/libgomp/testsuite/libgomp.oacc-fortran/stop-2.f b/libgomp/testsuite/libgomp.oacc-fortran/stop-2.f > index fe7ee37813a..394de034b1f 100644 > --- a/libgomp/testsuite/libgomp.oacc-fortran/stop-2.f > +++ b/libgomp/testsuite/libgomp.oacc-fortran/stop-2.f > @@ -17,7 +17,9 @@ > > ! { dg-output "CheCKpOInT(\n|\r\n|\r)+" } > > -! { dg-output "STOP 35(\n|\r\n|\r)+" } > +! '_gfortran_error_stop_numeric' -> '_gfortrani_st_printf' -> [...] > +! overflows the stack for nvptx offloading, thus XFAILed. > +! { dg-output "STOP 35(\n|\r\n|\r)+" { xfail openacc_nvidia_accel_selected } } > ! > ! PR85463. The 'exit' implementation used with nvptx > ! offloading is a little bit different. ----------------- 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 8c29332e98ca4669a059ebc0d90903b409ae049f Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Tue, 24 Jan 2023 10:29:01 +0100 Subject: [PATCH] Update 'libgomp/libgomp.texi' for 'nvptx, libgfortran: Switch out of "minimal" mode' libgomp/ * libgomp.texi (nvptx): Update for 'nvptx, libgfortran: Switch out of "minimal" mode'. --- libgomp/libgomp.texi | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libgomp/libgomp.texi b/libgomp/libgomp.texi index 896d187f1ff..17f1509343f 100644 --- a/libgomp/libgomp.texi +++ b/libgomp/libgomp.texi @@ -4448,7 +4448,7 @@ The used sizes are The implementation remark: @itemize -@item I/O within OpenMP target regions and OpenACC parallel/kernels is supported +@item I/O within OpenMP target regions and OpenACC compute regions is supported using the C library @code{printf} functions and the Fortran @code{print}/@code{write} statements. @end itemize @@ -4496,9 +4496,11 @@ CUDA version and hardware. The implementation remark: @itemize -@item I/O within OpenMP target regions and OpenACC parallel/kernels is supported - using the C library @code{printf} functions. Note that the Fortran - @code{print}/@code{write} statements are not supported, yet. +@item I/O within OpenMP target regions and OpenACC compute regions is supported + using the C library @code{printf} functions. + Additionally, the Fortran @code{print}/@code{write} statements are + supported within OpenMP target regions, but not yet OpenACC compute + regions. @item Compilation OpenMP code that contains @code{requires reverse_offload} requires at least @code{-march=sm_35}, compiling for @code{-march=sm_30} is not supported. -- 2.25.1