]>
Commit | Line | Data |
---|---|---|
cd33623e | 1 | #!/usr/bin/perl -w |
f7a9f785 | 2 | # Copyright (C) 1999-2016 Free Software Foundation, Inc. |
cd33623e UD |
3 | # This file is part of the GNU C Library. |
4 | # Contributed by Andreas Jaeger <aj@suse.de>, 1999. | |
5 | ||
6 | # The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
7 | # modify it under the terms of the GNU Lesser General Public |
8 | # License as published by the Free Software Foundation; either | |
9 | # version 2.1 of the License, or (at your option) any later version. | |
cd33623e UD |
10 | |
11 | # The GNU C Library is distributed in the hope that it will be useful, | |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 14 | # Lesser General Public License for more details. |
cd33623e | 15 | |
41bdb6e2 | 16 | # You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
17 | # License along with the GNU C Library; if not, see |
18 | # <http://www.gnu.org/licenses/>. | |
cd33623e UD |
19 | |
20 | # Information about tests are stored in: %results | |
21 | # $results{$test}{"type"} is the result type, e.g. normal or complex. | |
22 | # In the following description $platform, $type and $float are: | |
23 | # - $platform is the used platform | |
24 | # - $type is either "normal", "real" (for the real part of a complex number) | |
25 | # or "imag" (for the imaginary part # of a complex number). | |
26 | # - $float is either of float, ifloat, double, idouble, ldouble, ildouble; | |
27 | # It represents the underlying floating point type (float, double or long | |
28 | # double) and if inline functions (the leading i stands for inline) | |
29 | # are used. | |
30 | # $results{$test}{$platform}{$type}{$float} is defined and has a delta | |
31 | # or 'fail' as value. | |
32 | ||
33 | use File::Find; | |
34 | ||
35 | use strict; | |
36 | ||
37 | use vars qw ($sources @platforms %pplatforms); | |
38 | use vars qw (%results @all_floats %suffices @all_functions); | |
39 | ||
40 | ||
41 | # all_floats is in output order and contains all recognised float types that | |
42 | # we're going to output | |
43 | @all_floats = ('float', 'double', 'ldouble'); | |
44 | %suffices = | |
45 | ( 'float' => 'f', | |
46 | 'double' => '', | |
47 | 'ldouble' => 'l' | |
48 | ); | |
49 | ||
50 | # Pretty description of platform | |
79913103 | 51 | %pplatforms = (); |
cd33623e | 52 | |
41713d4e | 53 | @all_functions = |
cd33623e UD |
54 | ( "acos", "acosh", "asin", "asinh", "atan", "atanh", |
55 | "atan2", "cabs", "cacos", "cacosh", "carg", "casin", "casinh", | |
56 | "catan", "catanh", "cbrt", "ccos", "ccosh", "ceil", "cexp", "cimag", | |
57 | "clog", "clog10", "conj", "copysign", "cos", "cosh", "cpow", "cproj", | |
58 | "creal", "csin", "csinh", "csqrt", "ctan", "ctanh", "erf", "erfc", | |
59 | "exp", "exp10", "exp2", "expm1", "fabs", "fdim", "floor", "fma", | |
525f8039 | 60 | "fmax", "fmaxmag", "fmin", "fminmag", "fmod", "frexp", "gamma", "hypot", |
55a38f82 | 61 | "ilogb", "j0", "j1", "jn", "lgamma", "llogb", "lrint", |
cd33623e | 62 | "llrint", "log", "log10", "log1p", "log2", "logb", "lround", |
41a359e2 RS |
63 | "llround", "modf", "nearbyint", "nextafter", "nextdown", "nexttoward", |
64 | "nextup", "pow", "remainder", "remquo", "rint", "round", "scalb", | |
65 | "scalbn", "sin", "sincos", "sinh", "sqrt", "tan", "tanh", "tgamma", | |
cd33623e | 66 | "trunc", "y0", "y1", "yn" ); |
eaf5ad0b JM |
67 | # canonicalize, fpclassify, getpayload, iscanonical, isnormal, |
68 | # isfinite, isinf, isnan, issignaling, issubnormal, iszero, signbit, | |
69 | # iseqsig, isgreater, isgreaterequal, isless, islessequal, | |
457663a7 JM |
70 | # islessgreater, isunordered, setpayload, setpayloadsig, |
71 | # totalorder, totalordermag | |
cc6a8d74 | 72 | # are not tabulated. |
cd33623e UD |
73 | |
74 | if ($#ARGV == 0) { | |
75 | $sources = $ARGV[0]; | |
76 | } else { | |
77 | $sources = '/usr/src/cvs/libc'; | |
78 | } | |
79 | ||
80 | find (\&find_files, $sources); | |
81 | ||
41713d4e AJ |
82 | @platforms = sort by_platforms @platforms; |
83 | ||
cd33623e UD |
84 | &print_all; |
85 | ||
86 | sub find_files { | |
87 | if ($_ eq 'libm-test-ulps') { | |
88 | # print "Parsing $File::Find::name\n"; | |
89 | push @platforms, $File::Find::dir; | |
79913103 JM |
90 | my ($file, $name); |
91 | $file = "${File::Find::name}-name"; | |
92 | open NAME, $file or die ("Can't open $file: $!"); | |
93 | $name = <NAME>; | |
94 | chomp $name; | |
95 | close NAME; | |
96 | $pplatforms{$File::Find::dir} = $name; | |
cd33623e UD |
97 | &parse_ulps ($File::Find::name, $File::Find::dir); |
98 | } | |
99 | } | |
100 | ||
101 | # Parse ulps file | |
102 | sub parse_ulps { | |
103 | my ($file, $platform) = @_; | |
e6b6a857 | 104 | my ($test, $type, $float, $eps); |
cd33623e UD |
105 | |
106 | # $type has the following values: | |
107 | # "normal": No complex variable | |
108 | # "real": Real part of complex result | |
109 | # "imag": Imaginary part of complex result | |
110 | open ULP, $file or die ("Can't open $file: $!"); | |
111 | while (<ULP>) { | |
112 | chop; | |
113 | # ignore comments and empty lines | |
114 | next if /^#/; | |
115 | next if /^\s*$/; | |
cd33623e | 116 | if (/^Function: /) { |
6a7a8b22 | 117 | if (/Real part of/) { |
cd33623e UD |
118 | s/Real part of //; |
119 | $type = 'real'; | |
120 | } elsif (/Imaginary part of/) { | |
121 | s/Imaginary part of //; | |
122 | $type = 'imag'; | |
123 | } else { | |
124 | $type = 'normal'; | |
125 | } | |
126 | ($test) = ($_ =~ /^Function:\s*\"([a-zA-Z0-9_]+)\"/); | |
cd33623e UD |
127 | next; |
128 | } | |
cd33623e UD |
129 | if (/^i?(float|double|ldouble):/) { |
130 | ($float, $eps) = split /\s*:\s*/,$_,2; | |
131 | if ($eps eq 'fail') { | |
132 | $results{$test}{$platform}{$type}{$float} = 'fail'; | |
133 | } elsif ($eps eq "0") { | |
134 | # ignore | |
135 | next; | |
41713d4e | 136 | } elsif (!exists $results{$test}{$platform}{$type}{$float} |
cd33623e UD |
137 | || $results{$test}{$platform}{$type}{$float} ne 'fail') { |
138 | $results{$test}{$platform}{$type}{$float} = $eps; | |
139 | } | |
140 | if ($type =~ /^real|imag$/) { | |
141 | $results{$test}{'type'} = 'complex'; | |
142 | } elsif ($type eq 'normal') { | |
143 | $results{$test}{'type'} = 'normal'; | |
144 | } | |
145 | next; | |
146 | } | |
147 | print "Skipping unknown entry: `$_'\n"; | |
148 | } | |
149 | close ULP; | |
150 | } | |
151 | ||
152 | sub get_value { | |
153 | my ($fct, $platform, $type, $float) = @_; | |
154 | ||
41713d4e | 155 | return (exists $results{$fct}{$platform}{$type}{$float} |
cd33623e UD |
156 | ? $results{$fct}{$platform}{$type}{$float} : "0"); |
157 | } | |
158 | ||
41713d4e AJ |
159 | sub print_platforms { |
160 | my (@p) = @_; | |
161 | my ($fct, $platform, $float, $first, $i, $platform_no, $platform_total); | |
cd33623e UD |
162 | |
163 | print '@multitable {nexttowardf} '; | |
41713d4e | 164 | foreach (@p) { |
cd33623e UD |
165 | print ' {1000 + i 1000}'; |
166 | } | |
167 | print "\n"; | |
168 | ||
169 | print '@item Function '; | |
41713d4e | 170 | foreach (@p) { |
cd33623e | 171 | print ' @tab '; |
79913103 | 172 | print $pplatforms{$_}; |
cd33623e UD |
173 | } |
174 | print "\n"; | |
175 | ||
41713d4e | 176 | |
cd33623e UD |
177 | foreach $fct (@all_functions) { |
178 | foreach $float (@all_floats) { | |
179 | print "\@item $fct$suffices{$float} "; | |
41713d4e | 180 | foreach $platform (@p) { |
cd33623e UD |
181 | print ' @tab '; |
182 | if (exists $results{$fct}{$platform}{'normal'}{$float} | |
183 | || exists $results{$fct}{$platform}{'real'}{$float} | |
184 | || exists $results{$fct}{$platform}{'imag'}{$float}) { | |
185 | if ($results{$fct}{'type'} eq 'complex') { | |
186 | print &get_value ($fct, $platform, 'real', $float), | |
187 | ' + i ', &get_value ($fct, $platform, 'imag', $float); | |
188 | } else { | |
189 | print $results{$fct}{$platform}{'normal'}{$float}; | |
190 | } | |
191 | } else { | |
192 | print '-'; | |
193 | } | |
194 | } | |
195 | print "\n"; | |
196 | } | |
197 | } | |
198 | ||
199 | print "\@end multitable\n"; | |
200 | } | |
41713d4e AJ |
201 | |
202 | sub print_all { | |
203 | my ($i, $max); | |
204 | ||
205 | my ($columns) = 5; | |
206 | ||
207 | # Print only 5 platforms at a time. | |
208 | for ($i=0; $i < $#platforms; $i+=$columns) { | |
209 | $max = $i+$columns-1 > $#platforms ? $#platforms : $i+$columns-1; | |
210 | print_platforms (@platforms[$i .. $max]); | |
211 | } | |
212 | } | |
213 | ||
214 | sub by_platforms { | |
79913103 | 215 | return $pplatforms{$a} cmp $pplatforms{$b}; |
41713d4e | 216 | } |