]>
Commit | Line | Data |
---|---|---|
cd33623e | 1 | #!/usr/bin/perl -w |
688903eb | 2 | # Copyright (C) 1999-2018 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); | |
2b7dc4c8 | 38 | use vars qw (%results @all_floats %suffices %all_functions); |
cd33623e UD |
39 | |
40 | ||
41 | # all_floats is in output order and contains all recognised float types that | |
42 | # we're going to output | |
18a33677 | 43 | @all_floats = ('float', 'double', 'ldouble', 'float128'); |
cd33623e UD |
44 | %suffices = |
45 | ( 'float' => 'f', | |
46 | 'double' => '', | |
18a33677 GG |
47 | 'ldouble' => 'l', |
48 | 'float128' => 'f128' | |
cd33623e UD |
49 | ); |
50 | ||
51 | # Pretty description of platform | |
79913103 | 52 | %pplatforms = (); |
cd33623e | 53 | |
2b7dc4c8 | 54 | %all_functions = (); |
cd33623e UD |
55 | |
56 | if ($#ARGV == 0) { | |
57 | $sources = $ARGV[0]; | |
58 | } else { | |
59 | $sources = '/usr/src/cvs/libc'; | |
60 | } | |
61 | ||
62 | find (\&find_files, $sources); | |
63 | ||
41713d4e AJ |
64 | @platforms = sort by_platforms @platforms; |
65 | ||
cd33623e UD |
66 | &print_all; |
67 | ||
68 | sub find_files { | |
69 | if ($_ eq 'libm-test-ulps') { | |
70 | # print "Parsing $File::Find::name\n"; | |
71 | push @platforms, $File::Find::dir; | |
79913103 JM |
72 | my ($file, $name); |
73 | $file = "${File::Find::name}-name"; | |
74 | open NAME, $file or die ("Can't open $file: $!"); | |
75 | $name = <NAME>; | |
76 | chomp $name; | |
77 | close NAME; | |
78 | $pplatforms{$File::Find::dir} = $name; | |
cd33623e UD |
79 | &parse_ulps ($File::Find::name, $File::Find::dir); |
80 | } | |
81 | } | |
82 | ||
83 | # Parse ulps file | |
84 | sub parse_ulps { | |
85 | my ($file, $platform) = @_; | |
2b7dc4c8 | 86 | my ($test, $type, $float, $eps, $ignore_fn); |
cd33623e UD |
87 | |
88 | # $type has the following values: | |
89 | # "normal": No complex variable | |
90 | # "real": Real part of complex result | |
91 | # "imag": Imaginary part of complex result | |
92 | open ULP, $file or die ("Can't open $file: $!"); | |
93 | while (<ULP>) { | |
94 | chop; | |
95 | # ignore comments and empty lines | |
96 | next if /^#/; | |
97 | next if /^\s*$/; | |
cd33623e | 98 | if (/^Function: /) { |
6a7a8b22 | 99 | if (/Real part of/) { |
cd33623e UD |
100 | s/Real part of //; |
101 | $type = 'real'; | |
102 | } elsif (/Imaginary part of/) { | |
103 | s/Imaginary part of //; | |
104 | $type = 'imag'; | |
105 | } else { | |
106 | $type = 'normal'; | |
107 | } | |
108 | ($test) = ($_ =~ /^Function:\s*\"([a-zA-Z0-9_]+)\"/); | |
cd33623e UD |
109 | next; |
110 | } | |
2b7dc4c8 JM |
111 | if ($test =~ /_(downward|towardzero|upward|vlen)/) { |
112 | $ignore_fn = 1; | |
113 | } else { | |
114 | $ignore_fn = 0; | |
115 | $all_functions{$test} = 1; | |
116 | } | |
18a33677 | 117 | if (/^i?(float|double|ldouble|float128):/) { |
cd33623e | 118 | ($float, $eps) = split /\s*:\s*/,$_,2; |
2b7dc4c8 JM |
119 | if ($ignore_fn) { |
120 | next; | |
121 | } elsif ($eps eq 'fail') { | |
cd33623e UD |
122 | $results{$test}{$platform}{$type}{$float} = 'fail'; |
123 | } elsif ($eps eq "0") { | |
124 | # ignore | |
125 | next; | |
41713d4e | 126 | } elsif (!exists $results{$test}{$platform}{$type}{$float} |
cd33623e UD |
127 | || $results{$test}{$platform}{$type}{$float} ne 'fail') { |
128 | $results{$test}{$platform}{$type}{$float} = $eps; | |
129 | } | |
130 | if ($type =~ /^real|imag$/) { | |
131 | $results{$test}{'type'} = 'complex'; | |
132 | } elsif ($type eq 'normal') { | |
133 | $results{$test}{'type'} = 'normal'; | |
134 | } | |
135 | next; | |
136 | } | |
137 | print "Skipping unknown entry: `$_'\n"; | |
138 | } | |
139 | close ULP; | |
140 | } | |
141 | ||
142 | sub get_value { | |
143 | my ($fct, $platform, $type, $float) = @_; | |
144 | ||
41713d4e | 145 | return (exists $results{$fct}{$platform}{$type}{$float} |
cd33623e UD |
146 | ? $results{$fct}{$platform}{$type}{$float} : "0"); |
147 | } | |
148 | ||
41713d4e AJ |
149 | sub print_platforms { |
150 | my (@p) = @_; | |
151 | my ($fct, $platform, $float, $first, $i, $platform_no, $platform_total); | |
cd33623e UD |
152 | |
153 | print '@multitable {nexttowardf} '; | |
41713d4e | 154 | foreach (@p) { |
cd33623e UD |
155 | print ' {1000 + i 1000}'; |
156 | } | |
157 | print "\n"; | |
158 | ||
159 | print '@item Function '; | |
41713d4e | 160 | foreach (@p) { |
cd33623e | 161 | print ' @tab '; |
79913103 | 162 | print $pplatforms{$_}; |
cd33623e UD |
163 | } |
164 | print "\n"; | |
165 | ||
41713d4e | 166 | |
2b7dc4c8 | 167 | foreach $fct (sort keys %all_functions) { |
cd33623e UD |
168 | foreach $float (@all_floats) { |
169 | print "\@item $fct$suffices{$float} "; | |
41713d4e | 170 | foreach $platform (@p) { |
cd33623e UD |
171 | print ' @tab '; |
172 | if (exists $results{$fct}{$platform}{'normal'}{$float} | |
173 | || exists $results{$fct}{$platform}{'real'}{$float} | |
174 | || exists $results{$fct}{$platform}{'imag'}{$float}) { | |
175 | if ($results{$fct}{'type'} eq 'complex') { | |
176 | print &get_value ($fct, $platform, 'real', $float), | |
177 | ' + i ', &get_value ($fct, $platform, 'imag', $float); | |
178 | } else { | |
179 | print $results{$fct}{$platform}{'normal'}{$float}; | |
180 | } | |
181 | } else { | |
182 | print '-'; | |
183 | } | |
184 | } | |
185 | print "\n"; | |
186 | } | |
187 | } | |
188 | ||
189 | print "\@end multitable\n"; | |
190 | } | |
41713d4e AJ |
191 | |
192 | sub print_all { | |
193 | my ($i, $max); | |
194 | ||
195 | my ($columns) = 5; | |
196 | ||
197 | # Print only 5 platforms at a time. | |
198 | for ($i=0; $i < $#platforms; $i+=$columns) { | |
199 | $max = $i+$columns-1 > $#platforms ? $#platforms : $i+$columns-1; | |
200 | print_platforms (@platforms[$i .. $max]); | |
201 | } | |
202 | } | |
203 | ||
204 | sub by_platforms { | |
79913103 | 205 | return $pplatforms{$a} cmp $pplatforms{$b}; |
41713d4e | 206 | } |