This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch, testsuite, spu, fortran] Fix math-related failures
- From: Tobias Burnus <burnus at net-b dot de>
- To: Ulrich Weigand <uweigand at de dot ibm dot com>
- Cc: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Date: Thu, 16 Apr 2009 20:35:40 +0200
- Subject: Re: [patch, testsuite, spu, fortran] Fix math-related failures
- References: <200904161242.n3GCgCOQ001879@d12av02.megacenter.de.ibm.com>
Ulrich Weigand wrote:
> a number of Fortran testcases fail due to math-related problems. This affects
> in particular:
>
> - A number of test cases that cannot work on SPU because the single-precision
> floating point format does not support NaN, infinity, or denormal values.
> I've skipped those.
>
> - A number of test cases fail due to the round-to-zero default rounding mode,
> or due to imprecise single-precision arithmetic (division). I've XFAILed
> those for now, as (at least some of them) could probably be fixed by
> improving support for rounding modes in the Fortran frontend ...
>
That sounds as if there should be PR opened for this issue.
> Note that two cases can be made to pass by making the result check be a bit
> less strict in accepting rounding errors (due to round-to-zero, on the SPU
> multiple rounding errors tend to accumulate, while on other platforms, they
> might cancel).
>
> Tested on spu-elf.
> OK for mainline?
>
OK. Thanks for the patch, which is very close to being obvious.
Tobias
> ChangeLog:
>
> * gfortran.fortran-torture/execute/nan_inf_fmt.x: Skip on spu-*-*.
> * gfortran.fortran-torture/execute/intrinsic_nearest.x: Likewise.
> * gfortran.fortran-torture/execute/intrinsic_set_exponent.x: Likewise.
> * gfortran.dg/nearest_1.f90: Likewise.
> * gfortran.dg/nearest_3.f90: Likewise.
> * gfortran.dg/isnan_1.f90: Likewise.
> * gfortran.dg/isnan_2.f90: Likewise.
> * gfortran.dg/nan_1.f90: Likewise.
> * gfortran.dg/nan_2.f90: Likewise.
> * gfortran.dg/nan_3.f90: Likewise.
> * gfortran.dg/nan_4.f90: Likewise.
> * gfortran.dg/module_nan.f90: Likewise.
> * gfortran.dg/int_conv_2.f90: Likewise.
> * gfortran.dg/init_flag_3.f90: Likewise.
> * gfortran.dg/namelist_42.f90: Likewise.
> * gfortran.dg/namelist_43.f90: Likewise.
> * gfortran.dg/real_const_3.f90: Likewise.
> * gfortran.dg/transfer_simplify_1.f90: Likewise.
>
> * gfortran.dg/default_format_1.f90: XFAIL on spu-*-*.
> * gfortran.dg/default_format_denormal_1.f90: XFAIL on spu-*-*.
> * gfortran.dg/scalar_mask_2.f90: XFAIL on spu-*-*.
> * gfortran.dg/integer_exponentiation_3.F90: XFAIL on spu-*-*.
> * gfortran.dg/integer_exponentiation_5.F90: XFAIL on spu-*-*.
>
> * gfortran.dg/elemental_subroutine_1.f90: Relax "epsilon" check.
> * gfortran.dg/gamma_5.f90: Likewise.
>
>
> Index: gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_nearest.x
> ===================================================================
> *** gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_nearest.x (revision 144779)
> --- gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_nearest.x (working copy)
> ***************
> *** 1,2 ****
> --- 1,6 ----
> + if [istarget "spu-*-*"] {
> + # No Inf/NaN support on SPU.
> + return 1
> + }
> add-ieee-options
> return 0
> Index: gcc/testsuite/gfortran.fortran-torture/execute/nan_inf_fmt.x
> ===================================================================
> *** gcc/testsuite/gfortran.fortran-torture/execute/nan_inf_fmt.x (revision 144779)
> --- gcc/testsuite/gfortran.fortran-torture/execute/nan_inf_fmt.x (working copy)
> ***************
> *** 1,2 ****
> --- 1,6 ----
> + if [istarget "spu-*-*"] {
> + # No Inf/NaN support on SPU.
> + return 1
> + }
> add-ieee-options
> return 0
> Index: gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_set_exponent.x
> ===================================================================
> *** gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_set_exponent.x (revision 144779)
> --- gcc/testsuite/gfortran.fortran-torture/execute/intrinsic_set_exponent.x (working copy)
> ***************
> *** 1,2 ****
> --- 1,6 ----
> + if [istarget "spu-*-*"] {
> + # No denormal support on SPU.
> + return 1
> + }
> add-ieee-options
> return 0
> Index: gcc/testsuite/gfortran.dg/nearest_1.f90
> ===================================================================
> *** gcc/testsuite/gfortran.dg/nearest_1.f90 (revision 144779)
> --- gcc/testsuite/gfortran.dg/nearest_1.f90 (working copy)
> ***************
> *** 1,6 ****
> --- 1,7 ----
> ! { dg-do run }
> ! { dg-options "-O0 -ffloat-store" }
> ! { dg-options "-O0 -ffloat-store -mieee" { target alpha*-*-* } }
> + ! { dg-skip-if "Denormals not supported" { spu-*-* } { "*" } { "" } }
> ! PR fortran/27021
> ! Original code submitted by Dominique d'Humieres
> ! Converted to Dejagnu for the testsuite by Steven G. Kargl
> Index: gcc/testsuite/gfortran.dg/nearest_3.f90
> ===================================================================
> *** gcc/testsuite/gfortran.dg/nearest_3.f90 (revision 144779)
> --- gcc/testsuite/gfortran.dg/nearest_3.f90 (working copy)
> ***************
> *** 1,5 ****
> --- 1,6 ----
> ! { dg-do run }
> ! { dg-options "-pedantic-errors -mieee" { target alpha*-*-* sh*-*-* } }
> + ! { dg-skip-if "NaN not supported" { spu-*-* } { "*" } { "" } }
> !
> ! PR fortran/34209
> !
> Index: gcc/testsuite/gfortran.dg/isnan_1.f90
> ===================================================================
> *** gcc/testsuite/gfortran.dg/isnan_1.f90 (revision 144779)
> --- gcc/testsuite/gfortran.dg/isnan_1.f90 (working copy)
> ***************
> *** 2,7 ****
> --- 2,8 ----
> !
> ! { dg-do run }
> ! { dg-options "-pedantic-errors -mieee" { target alpha*-*-* sh*-*-* } }
> + ! { dg-skip-if "NaN not supported" { spu-*-* } { "*" } { "" } }
> !
> implicit none
> real :: x
> Index: gcc/testsuite/gfortran.dg/isnan_2.f90
> ===================================================================
> *** gcc/testsuite/gfortran.dg/isnan_2.f90 (revision 144779)
> --- gcc/testsuite/gfortran.dg/isnan_2.f90 (working copy)
> ***************
> *** 3,8 ****
> --- 3,9 ----
> ! { dg-do run }
> ! { dg-options "-fno-range-check" }
> ! { dg-options "-fno-range-check -pedantic-errors -mieee" { target alpha*-*-* sh*-*-* } }
> + ! { dg-skip-if "NaN not supported" { spu-*-* } { "*" } { "" } }
> !
> implicit none
> character(len=1) :: s
> Index: gcc/testsuite/gfortran.dg/nan_1.f90
> ===================================================================
> *** gcc/testsuite/gfortran.dg/nan_1.f90 (revision 144779)
> --- gcc/testsuite/gfortran.dg/nan_1.f90 (working copy)
> ***************
> *** 3,8 ****
> --- 3,9 ----
> !
> ! { dg-do run }
> ! { dg-options "-pedantic-errors -mieee" { target alpha*-*-* sh*-*-* } }
> + ! { dg-skip-if "NaN not supported" { spu-*-* } { "*" } { "" } }
> !
> module aux2
> interface isnan
> Index: gcc/testsuite/gfortran.dg/nan_2.f90
> ===================================================================
> *** gcc/testsuite/gfortran.dg/nan_2.f90 (revision 144779)
> --- gcc/testsuite/gfortran.dg/nan_2.f90 (working copy)
> ***************
> *** 1,6 ****
> --- 1,7 ----
> ! { dg-do run }
> ! { dg-options "-fno-range-check -pedantic" }
> ! { dg-options "-fno-range-check -pedantic -mieee" { target alpha*-*-* sh*-*-* } }
> + ! { dg-skip-if "NaN not supported" { spu-*-* } { "*" } { "" } }
> !
> ! PR fortran/34333
> !
> Index: gcc/testsuite/gfortran.dg/nan_3.f90
> ===================================================================
> *** gcc/testsuite/gfortran.dg/nan_3.f90 (revision 144779)
> --- gcc/testsuite/gfortran.dg/nan_3.f90 (working copy)
> ***************
> *** 1,6 ****
> --- 1,7 ----
> ! { dg-do run }
> ! { dg-options "-fno-range-check" }
> ! { dg-options "-fno-range-check -mieee" { target alpha*-*-* sh*-*-* } }
> + ! { dg-skip-if "NaN not supported" { spu-*-* } { "*" } { "" } }
> !
> ! PR fortran/34319
> !
> Index: gcc/testsuite/gfortran.dg/nan_4.f90
> ===================================================================
> *** gcc/testsuite/gfortran.dg/nan_4.f90 (revision 144779)
> --- gcc/testsuite/gfortran.dg/nan_4.f90 (working copy)
> ***************
> *** 1,6 ****
> --- 1,7 ----
> ! { dg-do compile }
> ! { dg-options "-std=gnu" }
> ! { dg-options "-std=gnu -mieee" { target alpha*-*-* sh*-*-* } }
> + ! { dg-skip-if "NaN not supported" { spu-*-* } { "*" } { "" } }
> !
> ! PR fortran/34398.
> !
> Index: gcc/testsuite/gfortran.dg/module_nan.f90
> ===================================================================
> *** gcc/testsuite/gfortran.dg/module_nan.f90 (revision 144779)
> --- gcc/testsuite/gfortran.dg/module_nan.f90 (working copy)
> ***************
> *** 1,6 ****
> --- 1,7 ----
> ! { dg-do run }
> ! { dg-options "-fno-range-check" }
> ! { dg-options "-fno-range-check -mieee" { target alpha*-*-* sh*-*-* } }
> + ! { dg-skip-if "NaN not supported" { spu-*-* } { "*" } { "" } }
> !
> ! PR fortran/34318
> !
> Index: gcc/testsuite/gfortran.dg/int_conv_2.f90
> ===================================================================
> *** gcc/testsuite/gfortran.dg/int_conv_2.f90 (revision 144779)
> --- gcc/testsuite/gfortran.dg/int_conv_2.f90 (working copy)
> ***************
> *** 1,4 ****
> --- 1,5 ----
> ! { dg-do compile }
> + ! { dg-skip-if "NaN not supported" { spu-*-* } { "*" } { "" } }
> ! PR fortran/37930
> program test
> implicit none
> Index: gcc/testsuite/gfortran.dg/init_flag_3.f90
> ===================================================================
> *** gcc/testsuite/gfortran.dg/init_flag_3.f90 (revision 144779)
> --- gcc/testsuite/gfortran.dg/init_flag_3.f90 (working copy)
> ***************
> *** 1,6 ****
> --- 1,7 ----
> ! { dg-do run }
> ! { dg-options "-finit-integer=-1 -finit-logical=false -finit-real=nan" }
> ! { dg-options "-finit-integer=-1 -finit-logical=false -finit-real=nan -mieee" { target alpha*-*-* sh*-*-* } }
> + ! { dg-skip-if "NaN not supported" { spu-*-* } { "*" } { "" } }
>
> program init_flag_3
> call real_test
> Index: gcc/testsuite/gfortran.dg/namelist_42.f90
> ===================================================================
> *** gcc/testsuite/gfortran.dg/namelist_42.f90 (revision 144779)
> --- gcc/testsuite/gfortran.dg/namelist_42.f90 (working copy)
> ***************
> *** 1,5 ****
> --- 1,6 ----
> ! { dg-do run { target fd_truncate } }
> ! { dg-options "-mieee" { target alpha*-*-* sh*-*-* } }
> + ! { dg-skip-if "NaN not supported" { spu-*-* } { "*" } { "" } }
> !
> ! PR fortran/34427
> !
> Index: gcc/testsuite/gfortran.dg/namelist_43.f90
> ===================================================================
> *** gcc/testsuite/gfortran.dg/namelist_43.f90 (revision 144779)
> --- gcc/testsuite/gfortran.dg/namelist_43.f90 (working copy)
> ***************
> *** 1,5 ****
> --- 1,6 ----
> ! { dg-do run { target fd_truncate } }
> ! { dg-options "-mieee" { target alpha*-*-* sh*-*-* } }
> + ! { dg-skip-if "NaN not supported" { spu-*-* } { "*" } { "" } }
> !
> ! PR fortran/34427
> !
> Index: gcc/testsuite/gfortran.dg/real_const_3.f90
> ===================================================================
> *** gcc/testsuite/gfortran.dg/real_const_3.f90 (revision 144779)
> --- gcc/testsuite/gfortran.dg/real_const_3.f90 (working copy)
> ***************
> *** 1,6 ****
> --- 1,7 ----
> !{ dg-do run }
> !{ dg-options "-fno-range-check" }
> !{ dg-options "-fno-range-check -mieee" { target alpha*-*-* sh*-*-* } }
> + !{ dg-skip-if "NaN not supported" { spu-*-* } { "*" } { "" } }
> ! PR19310 and PR19904, allow disabling range check during compile.
> ! Contributed by Jerry DeLisle <jvdelisle@gcc.gnu.org>
> program main
> Index: gcc/testsuite/gfortran.dg/transfer_simplify_1.f90
> ===================================================================
> *** gcc/testsuite/gfortran.dg/transfer_simplify_1.f90 (revision 144779)
> --- gcc/testsuite/gfortran.dg/transfer_simplify_1.f90 (working copy)
> ***************
> *** 1,5 ****
> --- 1,6 ----
> ! { dg-do run }
> ! { dg-options "-O2" }
> + ! { dg-skip-if "NaN not supported" { spu-*-* } { "*" } { "" } }
> ! Tests that the PRs caused by the lack of gfc_simplify_transfer are
> ! now fixed. These were brought together in the meta-bug PR31237
> ! (TRANSFER intrinsic).
> Index: gcc/testsuite/gfortran.dg/default_format_1.f90
> ===================================================================
> *** gcc/testsuite/gfortran.dg/default_format_1.f90 (revision 144779)
> --- gcc/testsuite/gfortran.dg/default_format_1.f90 (working copy)
> ***************
> *** 1,4 ****
> ! ! { dg-do run }
> ! Test XFAILed on Darwin because the system's printf() lacks
> ! proper support for denormals.
> !
> --- 1,4 ----
> ! ! { dg-do run { xfail spu-*-* } }
> ! Test XFAILed on Darwin because the system's printf() lacks
> ! proper support for denormals.
> !
> Index: gcc/testsuite/gfortran.dg/default_format_denormal_1.f90
> ===================================================================
> *** gcc/testsuite/gfortran.dg/default_format_denormal_1.f90 (revision 144779)
> --- gcc/testsuite/gfortran.dg/default_format_denormal_1.f90 (working copy)
> ***************
> *** 1,4 ****
> ! ! { dg-do run { xfail alpha*-*-* *-*-darwin[89]* *-*-freebsd* *-*-mingw* } }
> ! Test XFAILed on these platforms because the system's printf() lacks
> ! proper support for denormals.
> !
> --- 1,4 ----
> ! ! { dg-do run { xfail alpha*-*-* *-*-darwin[89]* *-*-freebsd* *-*-mingw* spu-*-* } }
> ! Test XFAILed on these platforms because the system's printf() lacks
> ! proper support for denormals.
> !
> Index: gcc/testsuite/gfortran.dg/scalar_mask_2.f90
> ===================================================================
> *** gcc/testsuite/gfortran.dg/scalar_mask_2.f90 (revision 144779)
> --- gcc/testsuite/gfortran.dg/scalar_mask_2.f90 (working copy)
> ***************
> *** 1,4 ****
> ! ! { dg-do run }
> program main
> ! Test scalar masks for different intrinsics.
> real, dimension(2,2) :: a
> --- 1,5 ----
> ! ! { dg-do run { xfail spu-*-* } }
> ! ! FAILs on SPU because of rounding error reading kinds.h
> program main
> ! Test scalar masks for different intrinsics.
> real, dimension(2,2) :: a
> Index: gcc/testsuite/gfortran.dg/integer_exponentiation_3.F90
> ===================================================================
> *** gcc/testsuite/gfortran.dg/integer_exponentiation_3.F90 (revision 144779)
> --- gcc/testsuite/gfortran.dg/integer_exponentiation_3.F90 (working copy)
> ***************
> *** 1,4 ****
> ! ! { dg-do run }
> ! { dg-options "" }
> module mod_check
> implicit none
> --- 1,5 ----
> ! ! { dg-do run { xfail spu-*-* } }
> ! ! FAILs on SPU because of wrong compile-time rounding mode
> ! { dg-options "" }
> module mod_check
> implicit none
> Index: gcc/testsuite/gfortran.dg/integer_exponentiation_5.F90
> ===================================================================
> *** gcc/testsuite/gfortran.dg/integer_exponentiation_5.F90 (revision 144779)
> --- gcc/testsuite/gfortran.dg/integer_exponentiation_5.F90 (working copy)
> ***************
> *** 1,4 ****
> ! ! { dg-do run }
> ! { dg-options "-fno-range-check" }
> ! { dg-options "-fno-range-check -mieee" { target alpha*-*-* } } */
> module mod_check
> --- 1,5 ----
> ! ! { dg-do run { xfail spu-*-* } }
> ! ! FAILs on SPU because of invalid result of 1.0/0.0 inline code
> ! { dg-options "-fno-range-check" }
> ! { dg-options "-fno-range-check -mieee" { target alpha*-*-* } } */
> module mod_check
> Index: gcc/testsuite/gfortran.dg/elemental_subroutine_1.f90
> ===================================================================
> *** gcc/testsuite/gfortran.dg/elemental_subroutine_1.f90 (revision 144779)
> --- gcc/testsuite/gfortran.dg/elemental_subroutine_1.f90 (working copy)
> *************** end module pr22146
> *** 48,54 ****
> ! Test an expression in the INTENT(IN) argument
> x = (/1.0, 2.0/)
> call foobar (cos (x) + u, y)
> ! if (any(abs (y + cos (x) + u) .gt. 2.0e-6)) call abort ()
>
> contains
>
> --- 48,54 ----
> ! Test an expression in the INTENT(IN) argument
> x = (/1.0, 2.0/)
> call foobar (cos (x) + u, y)
> ! if (any(abs (y + cos (x) + u) .gt. 4.0e-6)) call abort ()
>
> contains
>
> Index: gcc/testsuite/gfortran.dg/gamma_5.f90
> ===================================================================
> *** gcc/testsuite/gfortran.dg/gamma_5.f90 (revision 144779)
> --- gcc/testsuite/gfortran.dg/gamma_5.f90 (working copy)
> *************** program main
> *** 21,27 ****
> xd = n + 0.5d0
> td = c(n)*sqrt(pi)
> ts = c(n)*sqrt(pi)
> ! if (abs(gamma(xs)-ts)/ts > 3e-6) call abort
> if (abs(gamma(xd)-td)/td > 5e-14) call abort
> end do
> call tst_s(2.3, gamma(2.3))
> --- 21,27 ----
> xd = n + 0.5d0
> td = c(n)*sqrt(pi)
> ts = c(n)*sqrt(pi)
> ! if (abs(gamma(xs)-ts)/ts > 9e-6) call abort
> if (abs(gamma(xd)-td)/td > 5e-14) call abort
> end do
> call tst_s(2.3, gamma(2.3))
>