glibc/manual/libm-err-tab.pl

236 lines
6.7 KiB
Perl
Raw Normal View History

#!/usr/bin/perl -w
# Copyright (C) 1999-2016 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# Contributed by Andreas Jaeger <aj@suse.de>, 1999.
# The GNU C Library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# The GNU C Library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
# License along with the GNU C Library; if not, see
# <http://www.gnu.org/licenses/>.
# Information about tests are stored in: %results
# $results{$test}{"type"} is the result type, e.g. normal or complex.
# In the following description $platform, $type and $float are:
# - $platform is the used platform
# - $type is either "normal", "real" (for the real part of a complex number)
# or "imag" (for the imaginary part # of a complex number).
# - $float is either of float, ifloat, double, idouble, ldouble, ildouble;
# It represents the underlying floating point type (float, double or long
# double) and if inline functions (the leading i stands for inline)
# are used.
# $results{$test}{$platform}{$type}{$float} is defined and has a delta
# or 'fail' as value.
use File::Find;
use strict;
use vars qw ($sources @platforms %pplatforms);
use vars qw (%results @all_floats %suffices @all_functions);
# all_floats is in output order and contains all recognised float types that
# we're going to output
@all_floats = ('float', 'double', 'ldouble');
%suffices =
( 'float' => 'f',
'double' => '',
'ldouble' => 'l'
);
# Pretty description of platform
%pplatforms =
( "i386/fpu" => "ix86",
"generic" => "Generic",
"alpha/fpu" => "Alpha",
"ia64/fpu" => "IA64",
"m68k/fpu" => "M68k",
"mips/fpu" => "MIPS",
"powerpc/fpu" => "PowerPC",
"sparc/sparc32/fpu" => "Sparc 32-bit",
"sparc/sparc64/fpu" => "Sparc 64-bit",
"sh/sh4/fpu" => "SH4",
"s390/fpu" => "S/390",
"arm" => "ARM"
);
@all_functions =
( "acos", "acosh", "asin", "asinh", "atan", "atanh",
"atan2", "cabs", "cacos", "cacosh", "carg", "casin", "casinh",
"catan", "catanh", "cbrt", "ccos", "ccosh", "ceil", "cexp", "cimag",
"clog", "clog10", "conj", "copysign", "cos", "cosh", "cpow", "cproj",
"creal", "csin", "csinh", "csqrt", "ctan", "ctanh", "erf", "erfc",
"exp", "exp10", "exp2", "expm1", "fabs", "fdim", "floor", "fma",
"fmax", "fmin", "fmod", "frexp", "gamma", "hypot",
"ilogb", "j0", "j1", "jn", "lgamma", "lrint",
"llrint", "log", "log10", "log1p", "log2", "logb", "lround",
"llround", "modf", "nearbyint", "nextafter", "nextdown", "nexttoward",
"nextup", "pow", "remainder", "remquo", "rint", "round", "scalb",
"scalbn", "sin", "sincos", "sinh", "sqrt", "tan", "tanh", "tgamma",
"trunc", "y0", "y1", "yn" );
Add canonicalize, canonicalizef, canonicalizel. TS 18661-1 defines canonicalize functions to produce a canonical version of a floating-point representation. This patch implements these functions for glibc. As with the iscanonical macro, these functions are oriented to the decimal floating-point case, where some values have both canonical and noncanonical representations. However, the functions have a return value that says whether they succeeded in storing a canonical result; thus, they can fail for the case of an invalid representation (while still not making any particular choice from among multiple equally canonical valid representations of the same value). Since no floating-point formats in glibc actually have noncanonical valid representations, a type-generic implementation of these functions can be used that expects iscanonical to return 0 only for invalid representations. Now that iscanonical is used within libm.so, libm_hidden_proto / libm_hidden_def are added for __iscanonicall. The definition of these functions is intended to correspond to a convertFormat operation to the same floating-point format. Thus, they convert signaling NaNs to quiet NaNs, raising the "invalid" exception. Such a conversion "should" produce "the canonical version of that signaling NaN made quiet". libm-test.inc is made to check NaN payloads for the output of these functions, a new feature (at some point manipulation functions such as fabs and copysign should have tests added that verify payload preservation for them). As however some architectures may not follow the recommended practice of preserving NaN payloads when converting a signaling NaN to quiet, a new math-tests.h macro SNAN_TESTS_PRESERVE_PAYLOAD is added, and defined to 0 for non-NAN2008 MIPS; any other architectures seeing test failures for lack of payload preservation in this case should also define this macro to 0. (If any cases arise where the sign isn't preserved either, those should have a similar macro added.) The ldbl-96 and ldbl-128ibm tests of iscanonical are renamed and adapted to test canonicalizel as well on the same representations. Tested for x86_64, x86, mips64 and powerpc. * math/bits/mathcalls.h [__GLIBC_USE (IEC_60559_BFP_EXT)] (canonicalize): New declaration. * math/Versions (canonicalize): New libm symbol at version GLIBC_2.25. (canonicalizef): Likewise. (canonicalizel): Likewise. * math/Makefile (gen-libm-calls): Add s_canonicalizeF. * math/s_canonicalize_template.c: New file. * math/libm-test.inc: Update comment on functions tested and testing of NaN payloads. (TEST_NAN_PAYLOAD): New macro. (NO_TEST_INLINE): Update value. (XFAIL_TEST): Likewise. (ERRNO_UNCHANGED): Likewise. (ERRNO_EDOM): Likewise. (ERRNO_ERANGE): Likewise. (IGNORE_RESULT): Likewise. (NON_FINITE): Likewise. (TEST_SNAN): Likewise. (NO_TEST_MATHVEC): Likewise. (TEST_NAN_PAYLOAD_CANONICALIZE): New macro. (check_float_internal): Check NaN payloads if TEST_NAN_PAYLOAD. (struct test_Ffp_b1_data): New type. (RUN_TEST_Ffp_b1): New macro. (RUN_TEST_LOOP_Ffp_b1): Likewise. (canonicalize_test_data): New array. (canonicalize_test): New function. (main): Call canonicalize_test. * manual/arith.texi (FP Bit Twiddling): Document canonicalize, canonicalizef and canonicalizel. * manual/libm-err-tab.pl: Update comment on interfaces without ulps tabulated. * sysdeps/ieee754/ldbl-opt/nldbl-canonicalize.c: New file. * sysdeps/ieee754/ldbl-opt/s_canonicalizel.c: Likewise. * sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add canonicalize. (CFLAGS-nldbl-canonicalize.c): New variable. * sysdeps/ieee754/ldbl-128ibm/test-iscanonical-ldbl-128ibm.c: Move to ... * sysdeps/ieee754/ldbl-128ibm/test-canonical-ldbl-128ibm.c: ... here. (do_test): Also test canonicalizel. * sysdeps/ieee754/ldbl-128ibm/Makefile (tests): Change test-iscanonical-ldbl-128ibm to test-canonical-ldbl-128ibm. * sysdeps/ieee754/ldbl-128ibm/include/bits/iscanonical.h: New file. * sysdeps/ieee754/ldbl-128ibm/s_iscanonicall.c (__iscanonicall): Use libm_hidden_def. * sysdeps/ieee754/ldbl-96/test-iscanonical-ldbl-96.c: Move to ... * sysdeps/ieee754/ldbl-96/test-canonical-ldbl-96.c: ... here. (do_test): Also test canonicalizel. * sysdeps/ieee754/ldbl-96/Makefile (tests): Change test-iscanonical-ldbl-96 to test-canonical-ldbl-96. * sysdeps/ieee754/ldbl-96/include/bits/iscanonical.h: New file. * sysdeps/ieee754/ldbl-96/s_iscanonicall.c (__iscanonicall): Use libm_hidden_def. * sysdeps/generic/math-tests.h (SNAN_TESTS_PRESERVE_PAYLOAD): New macro. * sysdeps/mips/math-tests.h [__mips_hard_float && !__mips_nan2008] (SNAN_TESTS_PRESERVE_PAYLOAD): Likewise. * sysdeps/nacl/libm.abilist: Update. * sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
2016-10-26 23:14:31 +00:00
# canonicalize, fpclassify, getpayload, iscanonical, isnormal,
# isfinite, isinf, isnan, issignaling, issubnormal, iszero, signbit,
# iseqsig, isgreater, isgreaterequal, isless, islessequal,
# islessgreater, isunordered, totalorder, totalordermag
Add totalordermag, totalordermagf, totalordermagl. In addition to the totalorder functions, TS 18661-1 defines totalordermag functions, which do the same comparison but on the absolute values of the arguments. This patch implements these functions for glibc, including the type-generic macro in <tgmath.h>. In general the implementations are similar to but simpler than those for the totalorder functions. Tested for x86_64, x86, mips64 and powerpc. * math/bits/mathcalls.h [__GLIBC_USE (IEC_60559_BFP_EXT)] (totalordermag): New declaration. * math/tgmath.h [__GLIBC_USE (IEC_60559_BFP_EXT)] (totalordermag): New macro. * math/Versions (totalordermag): New libm symbol at version GLIBC_2.25. (totalordermagf): Likewise. (totalordermagl): Likewise. * math/Makefile (libm-calls): Add s_totalordermagF. * math/libm-test.inc (totalordermag_test_data): New array. (totalordermag_test): New function. (main): Call totalordermag_test. * math/test-tgmath.c (NCALLS): Increase to 125. (F(compile_test)): Call totalordermag. (F(totalordermag)): New function. * manual/arith.texi (FP Comparison Functions): Document totalordermag, totalordermagf and totalordermagl. * manual/libm-err-tab.pl: Update comment on interfaces without ulps tabulated. * sysdeps/ieee754/dbl-64/s_totalordermag.c: New file. * sysdeps/ieee754/dbl-64/wordsize-64/s_totalordermag.c: Likewise. * sysdeps/ieee754/flt-32/s_totalordermagf.c: Likewise. * sysdeps/ieee754/ldbl-128/s_totalordermagl.c: Likewise. * sysdeps/ieee754/ldbl-128ibm/s_totalordermagl.c: Likewise. * sysdeps/ieee754/ldbl-96/s_totalordermagl.c: Likewise. * sysdeps/ieee754/ldbl-opt/nldbl-totalordermag.c: Likewise. * sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add totalordermag. (CFLAGS-nldbl-totalordermag.c): New variable. * sysdeps/ieee754/ldbl-128ibm/test-totalorderl-ldbl-128ibm.c (do_test): Also test totalordermagl. * sysdeps/ieee754/ldbl-96/test-totalorderl-ldbl-96.c (do_test): Likewise. * sysdeps/nacl/libm.abilist: Update. * sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
2016-10-15 00:36:48 +00:00
# are not tabulated.
if ($#ARGV == 0) {
$sources = $ARGV[0];
} else {
$sources = '/usr/src/cvs/libc';
}
find (\&find_files, $sources);
@platforms = sort by_platforms @platforms;
&print_all;
sub find_files {
if ($_ eq 'libm-test-ulps') {
# print "Parsing $File::Find::name\n";
push @platforms, $File::Find::dir;
&parse_ulps ($File::Find::name, $File::Find::dir);
}
}
# Parse ulps file
sub parse_ulps {
my ($file, $platform) = @_;
Don't include individual test ulps in libm-test-ulps. As recently discussed <https://sourceware.org/ml/libc-alpha/2014-02/msg00670.html>, it doesn't seem particularly useful for libm-test-ulps files to contain huge amounts of data on ulps for individual tests; just the global maximum observed ulps for each function, together with the verification of exceptions, errno and special results such as infinities and NaNs for each test, suffices to verify that a function's behavior on the given test inputs is within the expected accuracy. Removing this data reduces source tree churn caused by updates to these files when libm tests are added, and reduces the frequency with which testsuite additions actually need libm-test-ulps changes at all. Accordingly, this patch removes that data, so that individual tests get checked against the global bounds for the given function and only generate an error if those are exceeded. Tested x86_64 (including verifying that if an ulps value is artificially reduced, the tests do indeed fail as they should and "make regen-ulps" generates the expected changes). * math/libm-test.inc (struct ulp_data): Don't refer to ulps for individual tests in comment. (libm-test-ulps.h): Don't refer to test_ulps in #include comment. (prev_max_error): New variable. (prev_real_max_error): Likewise. (prev_imag_max_error): Likewise. (compare_ulp_data): Don't refer to test names in comment. (find_test_ulps): Remove function. (find_function_ulps): Likewise. (find_complex_function_ulps): Likewise. (init_max_error): Take function name as argument. Look up ulps for that function. (print_ulps): Remove function. (print_max_error): Use prev_max_error instead of calling find_function_ulps. (print_complex_max_error): Use prev_real_max_error and prev_imag_max_error instead of calling find_complex_function_ulps. (check_float_internal): Take max_ulp parameter instead of calling find_test_ulps. Don't call print_ulps. (check_float): Update call to check_float_internal. (check_complex): Update calls to check_float_internal. (START): Pass argument to init_max_error. * math/gen-libm-test.pl (%results): Don't include "kind" information. (parse_ulps): Don't handle ulps of individual tests. (print_ulps_file): Likewise. (output_ulps): Likewise. * math/README.libm-test: Update. * manual/libm-err-tab.pl (parse_ulps): Don't handle ulps of individual tests. * sysdeps/aarch64/libm-test-ulps: Remove individual test ulps. * sysdeps/alpha/fpu/libm-test-ulps: Likewise. * sysdeps/arm/libm-test-ulps: Likewise. * sysdeps/i386/fpu/libm-test-ulps: Likewise. * sysdeps/ia64/fpu/libm-test-ulps: Likewise. * sysdeps/m68k/coldfire/fpu/libm-test-ulps: Likewise. * sysdeps/m68k/m680x0/fpu/libm-test-ulps: Likewise. * sysdeps/microblaze/libm-test-ulps: Likewise. * sysdeps/mips/mips32/libm-test-ulps: Likewise. * sysdeps/mips/mips64/libm-test-ulps: Likewise. * sysdeps/powerpc/fpu/libm-test-ulps: Likewise. * sysdeps/powerpc/nofpu/libm-test-ulps: Likewise. * sysdeps/s390/fpu/libm-test-ulps: Likewise. * sysdeps/sh/libm-test-ulps: Likewise. * sysdeps/sparc/fpu/libm-test-ulps: Likewise. * sysdeps/tile/libm-test-ulps: Likewise. * sysdeps/x86_64/fpu/libm-test-ulps: Likewise. * sysdeps/hppa/fpu/libm-test-ulps: Remove individual test ulps.
2014-03-05 15:02:38 +00:00
my ($test, $type, $float, $eps);
# $type has the following values:
# "normal": No complex variable
# "real": Real part of complex result
# "imag": Imaginary part of complex result
open ULP, $file or die ("Can't open $file: $!");
while (<ULP>) {
chop;
# ignore comments and empty lines
next if /^#/;
next if /^\s*$/;
if (/^Function: /) {
if (/Real part of/) {
s/Real part of //;
$type = 'real';
} elsif (/Imaginary part of/) {
s/Imaginary part of //;
$type = 'imag';
} else {
$type = 'normal';
}
($test) = ($_ =~ /^Function:\s*\"([a-zA-Z0-9_]+)\"/);
next;
}
if (/^i?(float|double|ldouble):/) {
($float, $eps) = split /\s*:\s*/,$_,2;
if ($eps eq 'fail') {
$results{$test}{$platform}{$type}{$float} = 'fail';
} elsif ($eps eq "0") {
# ignore
next;
} elsif (!exists $results{$test}{$platform}{$type}{$float}
|| $results{$test}{$platform}{$type}{$float} ne 'fail') {
$results{$test}{$platform}{$type}{$float} = $eps;
}
if ($type =~ /^real|imag$/) {
$results{$test}{'type'} = 'complex';
} elsif ($type eq 'normal') {
$results{$test}{'type'} = 'normal';
}
next;
}
print "Skipping unknown entry: `$_'\n";
}
close ULP;
}
sub get_value {
my ($fct, $platform, $type, $float) = @_;
return (exists $results{$fct}{$platform}{$type}{$float}
? $results{$fct}{$platform}{$type}{$float} : "0");
}
sub canonicalize_platform {
my ($platform) = @_;
$platform =~ s|^(.*/sysdeps/)||;
return exists $pplatforms{$platform} ? $pplatforms{$platform} : $platform;
}
sub print_platforms {
my (@p) = @_;
my ($fct, $platform, $float, $first, $i, $platform_no, $platform_total);
print '@multitable {nexttowardf} ';
foreach (@p) {
print ' {1000 + i 1000}';
}
print "\n";
print '@item Function ';
foreach (@p) {
print ' @tab ';
print &canonicalize_platform ($_);
}
print "\n";
foreach $fct (@all_functions) {
foreach $float (@all_floats) {
print "\@item $fct$suffices{$float} ";
foreach $platform (@p) {
print ' @tab ';
if (exists $results{$fct}{$platform}{'normal'}{$float}
|| exists $results{$fct}{$platform}{'real'}{$float}
|| exists $results{$fct}{$platform}{'imag'}{$float}) {
if ($results{$fct}{'type'} eq 'complex') {
print &get_value ($fct, $platform, 'real', $float),
' + i ', &get_value ($fct, $platform, 'imag', $float);
} else {
print $results{$fct}{$platform}{'normal'}{$float};
}
} else {
print '-';
}
}
print "\n";
}
}
print "\@end multitable\n";
}
sub print_all {
my ($i, $max);
my ($columns) = 5;
# Print only 5 platforms at a time.
for ($i=0; $i < $#platforms; $i+=$columns) {
$max = $i+$columns-1 > $#platforms ? $#platforms : $i+$columns-1;
print_platforms (@platforms[$i .. $max]);
}
}
sub by_platforms {
my ($pa, $pb);
$pa = $pplatforms{$a} ? $pplatforms{$a} : $a;
$pb = $pplatforms{$b} ? $pplatforms{$b} : $b;
2013-06-05 20:44:03 +00:00
return $pa cmp $pb;
}