diff options
Diffstat (limited to 'math')
-rwxr-xr-x | math/libm-err-tab.pl | 207 | ||||
-rw-r--r-- | math/libm-test.inc | 17 |
2 files changed, 221 insertions, 3 deletions
diff --git a/math/libm-err-tab.pl b/math/libm-err-tab.pl new file mode 100755 index 0000000000..448bf801ab --- /dev/null +++ b/math/libm-err-tab.pl @@ -0,0 +1,207 @@ +#!/usr/bin/perl -w + +# Copyright (C) 1999 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 Library General Public License as +# published by the Free Software Foundation; either version 2 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 +# Library General Public License for more details. + +# You should have received a copy of the GNU Library General Public +# License along with the GNU C Library; see the file COPYING.LIB. If not, +# write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# 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" => "Alpha" + ); + +@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", "nexttoward", "pow", + "remainder", "remquo", "rint", "round", "scalb", "scalbn", "scalbln", + "sin", "sincos", "sinh", "sqrt", "tan", "tanh", "tgamma", + "trunc", "y0", "y1", "yn" ); +# "fpclassify", "isfinite", "isnormal", "signbit" are not tabulated + +if ($#ARGV == 0) { + $sources = $ARGV[0]; +} else { + $sources = '/usr/src/cvs/libc'; +} + +find (\&find_files, $sources); + +&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) = @_; + my ($test, $type, $float, $eps, $kind); + + # $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 (/^Test/) { + $kind = 'test'; + next; + } + 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_]+)\"/); + $kind = 'fct'; + next; + } + # Only handle maximal errors of functions + next if ($kind eq 'test'); + 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_all { + my ($fct, $platform, $float, $first, $i); + + print '@multitable {nexttowardf} '; + foreach (@platforms) { + print ' {1000 + i 1000}'; + } + print "\n"; + + print '@item Function '; + foreach (@platforms) { + print ' @tab '; + print &canonicalize_platform ($_); + } + print "\n"; + + + foreach $fct (@all_functions) { + foreach $float (@all_floats) { + print "\@item $fct$suffices{$float} "; + foreach $platform (@platforms) { + 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"; +} diff --git a/math/libm-test.inc b/math/libm-test.inc index 71a846f94f..d2ceb2ff69 100644 --- a/math/libm-test.inc +++ b/math/libm-test.inc @@ -158,6 +158,7 @@ static int noXPasses; /* number of unexpected passes. */ static int verbose; static int output_max_error; /* Should the maximal errors printed? */ static int output_points; /* Should the single function results printed? */ +static int ignore_max_ulp; /* Should we ignore max_ulp? */ static FLOAT minus_zero, plus_zero; static FLOAT plus_infty, minus_infty, nan_value; @@ -315,7 +316,7 @@ print_max_error (const char *func_name, FLOAT allowed, int xfail) { int ok = 0; - if (max_error <= allowed) + if (max_error == 0.0 || (max_error <= allowed && !ignore_max_ulp)) { ok = 1; } @@ -477,7 +478,7 @@ check_float_internal (const char *test_name, FLOAT computed, FLOAT expected, && (computed == 0.0 && expected == 0.0 && signbit(computed) != signbit (expected))) ok = 0; - else if (ulp <= max_ulp) + else if (ulp == 0.0 || (ulp <= max_ulp && !ignore_max_ulp)) ok = 1; else { @@ -3875,6 +3876,8 @@ static const struct argp_option options[] = "Don't output maximal errors of functions"}, { "no-points", 'p', NULL, 0, "Don't output results of functions invocations"}, + { "ignore-max-ulp", 'i', "yes/no", 0, + "Ignore given maximal errors"}, { NULL, 0, NULL, 0, NULL } }; @@ -3900,6 +3903,12 @@ parse_opt (int key, char *arg, struct argp_state *state) case 'f': output_max_error = 0; break; + case 'i': + if (strcmp (arg, "yes") == 0) + ignore_max_ulp = 1; + else if (strcmp (arg, "no") == 0) + ignore_max_ulp = 0; + break; case 'p': output_points = 0; break; @@ -3954,7 +3963,9 @@ main (int argc, char **argv) output_ulps = 0; output_max_error = 1; output_points = 1; - + /* XXX set to 0 for releases. */ + ignore_max_ulp = 0; + /* Parse and process arguments. */ argp_parse (&argp, argc, argv, 0, &remaining, NULL); |