• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3# ULP error check script.
4#
5# Copyright (c) 2019-2020, Arm Limited.
6# SPDX-License-Identifier: MIT
7
8#set -x
9set -eu
10
11# cd to bin directory.
12cd "${0%/*}"
13
14rmodes='n u d z'
15#rmodes=n
16flags="${ULPFLAGS:--q}"
17emu="$@"
18
19FAIL=0
20PASS=0
21
22t() {
23	[ $r = "n" ] && Lt=$L || Lt=$Ldir
24	$emu ./ulp -r $r -e $Lt $flags "$@" && PASS=$((PASS+1)) || FAIL=$((FAIL+1))
25}
26
27check() {
28	$emu ./ulp -f -q "$@" >/dev/null
29}
30
31Ldir=0.5
32for r in $rmodes
33do
34L=0.01
35t exp  0 0xffff000000000000 10000
36t exp  0x1p-6     0x1p6     40000
37t exp -0x1p-6    -0x1p6     40000
38t exp  633.3      733.3     10000
39t exp -633.3     -777.3     10000
40
41L=0.01
42t exp2  0 0xffff000000000000 10000
43t exp2  0x1p-6     0x1p6     40000
44t exp2 -0x1p-6    -0x1p6     40000
45t exp2  633.3      733.3     10000
46t exp2 -633.3     -777.3     10000
47
48L=0.02
49t log  0 0xffff000000000000 10000
50t log  0x1p-4    0x1p4      40000
51t log  0         inf        40000
52
53L=0.05
54t log2  0 0xffff000000000000 10000
55t log2  0x1p-4    0x1p4      40000
56t log2  0         inf        40000
57
58L=0.05
59t pow  0.5  2.0  x  0  inf 20000
60t pow -0.5 -2.0  x  0  inf 20000
61t pow  0.5  2.0  x -0 -inf 20000
62t pow -0.5 -2.0  x -0 -inf 20000
63t pow  0.5  2.0  x  0x1p-10  0x1p10  40000
64t pow  0.5  2.0  x -0x1p-10 -0x1p10  40000
65t pow  0    inf  x    0.5      2.0   80000
66t pow  0    inf  x   -0.5     -2.0   80000
67t pow  0x1.fp-1   0x1.08p0  x  0x1p8 0x1p17  80000
68t pow  0x1.fp-1   0x1.08p0  x -0x1p8 -0x1p17 80000
69t pow  0         0x1p-1000  x  0 1.0 50000
70t pow  0x1p1000        inf  x  0 1.0 50000
71t pow  0x1.ffffffffffff0p-1  0x1.0000000000008p0 x 0x1p60 0x1p68 50000
72t pow  0x1.ffffffffff000p-1  0x1p0 x 0x1p50 0x1p52 50000
73t pow -0x1.ffffffffff000p-1 -0x1p0 x 0x1p50 0x1p52 50000
74
75L=1.0
76Ldir=0.9
77t erf  0 0xffff000000000000 10000
78t erf  0x1p-1022  0x1p-26   40000
79t erf  -0x1p-1022 -0x1p-26  40000
80t erf  0x1p-26    0x1p3     40000
81t erf  -0x1p-26  -0x1p3     40000
82t erf  0         inf        40000
83Ldir=0.5
84
85L=0.01
86t expf  0    0xffff0000    10000
87t expf  0x1p-14   0x1p8    50000
88t expf -0x1p-14  -0x1p8    50000
89
90L=0.01
91t exp2f  0    0xffff0000   10000
92t exp2f  0x1p-14   0x1p8   50000
93t exp2f -0x1p-14  -0x1p8   50000
94
95L=0.32
96t logf  0    0xffff0000    10000
97t logf  0x1p-4    0x1p4    50000
98t logf  0         inf      50000
99
100L=0.26
101t log2f  0    0xffff0000   10000
102t log2f  0x1p-4    0x1p4   50000
103t log2f  0         inf     50000
104
105L=0.06
106t sinf  0    0xffff0000    10000
107t sinf  0x1p-14  0x1p54    50000
108t sinf -0x1p-14 -0x1p54    50000
109
110L=0.06
111t cosf  0    0xffff0000    10000
112t cosf  0x1p-14  0x1p54    50000
113t cosf -0x1p-14 -0x1p54    50000
114
115L=0.06
116t sincosf_sinf  0    0xffff0000    10000
117t sincosf_sinf  0x1p-14  0x1p54    50000
118t sincosf_sinf -0x1p-14 -0x1p54    50000
119
120L=0.06
121t sincosf_cosf  0    0xffff0000    10000
122t sincosf_cosf  0x1p-14  0x1p54    50000
123t sincosf_cosf -0x1p-14 -0x1p54    50000
124
125L=0.4
126t powf  0x1p-1   0x1p1  x  0x1p-7 0x1p7   50000
127t powf  0x1p-1   0x1p1  x -0x1p-7 -0x1p7  50000
128t powf  0x1p-70 0x1p70  x  0x1p-1 0x1p1   50000
129t powf  0x1p-70 0x1p70  x  -0x1p-1 -0x1p1 50000
130t powf  0x1.ep-1 0x1.1p0 x  0x1p8 0x1p14  50000
131t powf  0x1.ep-1 0x1.1p0 x -0x1p8 -0x1p14 50000
132
133L=0.6
134Ldir=0.9
135t erff  0      0xffff0000 10000
136t erff  0x1p-127  0x1p-26 40000
137t erff -0x1p-127 -0x1p-26 40000
138t erff  0x1p-26   0x1p3   40000
139t erff -0x1p-26  -0x1p3   40000
140t erff  0         inf     40000
141Ldir=0.5
142
143done
144
145# vector functions
146Ldir=0.5
147r='n'
148flags="${ULPFLAGS:--q} -f"
149runs=
150check __s_exp 1 && runs=1
151runv=
152check __v_exp 1 && runv=1
153runvn=
154check __vn_exp 1 && runvn=1
155
156range_exp='
157  0 0xffff000000000000 10000
158  0x1p-6     0x1p6     400000
159 -0x1p-6    -0x1p6     400000
160  633.3      733.3     10000
161 -633.3     -777.3     10000
162'
163
164range_log='
165  0 0xffff000000000000 10000
166  0x1p-4     0x1p4     400000
167  0          inf       400000
168'
169
170range_pow='
171 0x1p-1   0x1p1  x  0x1p-10 0x1p10   50000
172 0x1p-1   0x1p1  x -0x1p-10 -0x1p10  50000
173 0x1p-500 0x1p500  x  0x1p-1 0x1p1   50000
174 0x1p-500 0x1p500  x  -0x1p-1 -0x1p1 50000
175 0x1.ep-1 0x1.1p0 x  0x1p8 0x1p16    50000
176 0x1.ep-1 0x1.1p0 x -0x1p8 -0x1p16   50000
177'
178
179range_sin='
180  0 0xffff000000000000 10000
181  0x1p-4     0x1p4     400000
182 -0x1p-23    0x1p23    400000
183'
184range_cos="$range_sin"
185
186range_expf='
187  0    0xffff0000    10000
188  0x1p-14   0x1p8    500000
189 -0x1p-14  -0x1p8    500000
190'
191
192range_expf_1u="$range_expf"
193range_exp2f="$range_expf"
194range_exp2f_1u="$range_expf"
195
196range_logf='
197 0    0xffff0000    10000
198 0x1p-4    0x1p4    500000
199'
200
201range_sinf='
202 0    0xffff0000    10000
203 0x1p-4    0x1p4    300000
204-0x1p-9   -0x1p9    300000
205'
206range_cosf="$range_sinf"
207
208range_powf='
209 0x1p-1   0x1p1  x  0x1p-7 0x1p7   50000
210 0x1p-1   0x1p1  x -0x1p-7 -0x1p7  50000
211 0x1p-70 0x1p70  x  0x1p-1 0x1p1   50000
212 0x1p-70 0x1p70  x  -0x1p-1 -0x1p1 50000
213 0x1.ep-1 0x1.1p0 x  0x1p8 0x1p14  50000
214 0x1.ep-1 0x1.1p0 x -0x1p8 -0x1p14 50000
215'
216
217# error limits
218L_exp=1.9
219L_log=1.2
220L_pow=0.05
221L_sin=3.0
222L_cos=3.0
223L_expf=1.49
224L_expf_1u=0.4
225L_exp2f=1.49
226L_exp2f_1u=0.4
227L_logf=2.9
228L_sinf=1.4
229L_cosf=1.4
230L_powf=2.1
231
232while read G F R
233do
234	[ "$R" = 1 ] || continue
235	case "$G" in \#*) continue ;; esac
236	eval range="\${range_$G}"
237	eval L="\${L_$G}"
238	while read X
239	do
240		[ -n "$X" ] || continue
241		case "$X" in \#*) continue ;; esac
242		t $F $X
243	done << EOF
244$range
245EOF
246done << EOF
247# group symbol run
248exp  __s_exp       $runs
249exp  __v_exp       $runv
250exp  __vn_exp      $runvn
251exp  _ZGVnN2v_exp  $runvn
252
253log  __s_log       $runs
254log  __v_log       $runv
255log  __vn_log      $runvn
256log  _ZGVnN2v_log  $runvn
257
258pow __s_pow       $runs
259pow __v_pow       $runv
260pow __vn_pow      $runvn
261pow _ZGVnN2vv_pow $runvn
262
263sin __s_sin       $runs
264sin __v_sin       $runv
265sin __vn_sin      $runvn
266sin _ZGVnN2v_sin  $runvn
267
268cos __s_cos       $runs
269cos __v_cos       $runv
270cos __vn_cos      $runvn
271cos _ZGVnN2v_cos  $runvn
272
273expf __s_expf      $runs
274expf __v_expf      $runv
275expf __vn_expf     $runvn
276expf _ZGVnN4v_expf $runvn
277
278expf_1u __s_expf_1u   $runs
279expf_1u __v_expf_1u   $runv
280expf_1u __vn_expf_1u  $runvn
281
282exp2f __s_exp2f      $runs
283exp2f __v_exp2f      $runv
284exp2f __vn_exp2f     $runvn
285exp2f _ZGVnN4v_exp2f $runvn
286
287exp2f_1u __s_exp2f_1u  $runs
288exp2f_1u __v_exp2f_1u  $runv
289exp2f_1u __vn_exp2f_1u $runvn
290
291logf __s_logf      $runs
292logf __v_logf      $runv
293logf __vn_logf     $runvn
294logf _ZGVnN4v_logf $runvn
295
296sinf __s_sinf      $runs
297sinf __v_sinf      $runv
298sinf __vn_sinf     $runvn
299sinf _ZGVnN4v_sinf $runvn
300
301cosf __s_cosf      $runs
302cosf __v_cosf      $runv
303cosf __vn_cosf     $runvn
304cosf _ZGVnN4v_cosf $runvn
305
306powf __s_powf       $runs
307powf __v_powf       $runv
308powf __vn_powf      $runvn
309powf _ZGVnN4vv_powf $runvn
310EOF
311
312[ 0 -eq $FAIL ] || {
313	echo "FAILED $FAIL PASSED $PASS"
314	exit 1
315}
316