1#!/bin/bash 2 3# ULP error check script. 4# 5# Copyright (c) 2019-2023, Arm Limited. 6# SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception 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=0.02 76t exp10 0 0x1p-47 5000 77t exp10 -0 -0x1p-47 5000 78t exp10 0x1p-47 1 50000 79t exp10 -0x1p-47 -1 50000 80t exp10 1 0x1.34413509f79ffp8 50000 81t exp10 -1 -0x1.434e6420f4374p8 50000 82t exp10 0x1.34413509f79ffp8 inf 5000 83t exp10 -0x1.434e6420f4374p8 -inf 5000 84 85L=1.0 86Ldir=0.9 87t erf 0 0xffff000000000000 10000 88t erf 0x1p-1022 0x1p-26 40000 89t erf -0x1p-1022 -0x1p-26 40000 90t erf 0x1p-26 0x1p3 40000 91t erf -0x1p-26 -0x1p3 40000 92t erf 0 inf 40000 93Ldir=0.5 94 95L=0.01 96t expf 0 0xffff0000 10000 97t expf 0x1p-14 0x1p8 50000 98t expf -0x1p-14 -0x1p8 50000 99 100L=0.01 101t exp2f 0 0xffff0000 10000 102t exp2f 0x1p-14 0x1p8 50000 103t exp2f -0x1p-14 -0x1p8 50000 104 105L=0.32 106t logf 0 0xffff0000 10000 107t logf 0x1p-4 0x1p4 50000 108t logf 0 inf 50000 109 110L=0.26 111t log2f 0 0xffff0000 10000 112t log2f 0x1p-4 0x1p4 50000 113t log2f 0 inf 50000 114 115L=0.06 116t sinf 0 0xffff0000 10000 117t sinf 0x1p-14 0x1p54 50000 118t sinf -0x1p-14 -0x1p54 50000 119 120L=0.06 121t cosf 0 0xffff0000 10000 122t cosf 0x1p-14 0x1p54 50000 123t cosf -0x1p-14 -0x1p54 50000 124 125L=0.06 126t sincosf_sinf 0 0xffff0000 10000 127t sincosf_sinf 0x1p-14 0x1p54 50000 128t sincosf_sinf -0x1p-14 -0x1p54 50000 129 130L=0.06 131t sincosf_cosf 0 0xffff0000 10000 132t sincosf_cosf 0x1p-14 0x1p54 50000 133t sincosf_cosf -0x1p-14 -0x1p54 50000 134 135L=0.4 136t powf 0x1p-1 0x1p1 x 0x1p-7 0x1p7 50000 137t powf 0x1p-1 0x1p1 x -0x1p-7 -0x1p7 50000 138t powf 0x1p-70 0x1p70 x 0x1p-1 0x1p1 50000 139t powf 0x1p-70 0x1p70 x -0x1p-1 -0x1p1 50000 140t powf 0x1.ep-1 0x1.1p0 x 0x1p8 0x1p14 50000 141t powf 0x1.ep-1 0x1.1p0 x -0x1p8 -0x1p14 50000 142 143L=0.6 144Ldir=0.9 145t erff 0 0xffff0000 10000 146t erff 0x1p-127 0x1p-26 40000 147t erff -0x1p-127 -0x1p-26 40000 148t erff 0x1p-26 0x1p3 40000 149t erff -0x1p-26 -0x1p3 40000 150t erff 0 inf 40000 151Ldir=0.5 152 153done 154 155# vector functions 156 157Ldir=0.5 158r='n' 159flags="${ULPFLAGS:--q}" 160 161range_exp=' 162 0 0xffff000000000000 10000 163 0x1p-6 0x1p6 400000 164 -0x1p-6 -0x1p6 400000 165 633.3 733.3 10000 166 -633.3 -777.3 10000 167' 168 169range_log=' 170 0 0xffff000000000000 10000 171 0x1p-4 0x1p4 400000 172 0 inf 400000 173' 174 175range_pow=' 176 0x1p-1 0x1p1 x 0x1p-10 0x1p10 50000 177 0x1p-1 0x1p1 x -0x1p-10 -0x1p10 50000 178 0x1p-500 0x1p500 x 0x1p-1 0x1p1 50000 179 0x1p-500 0x1p500 x -0x1p-1 -0x1p1 50000 180 0x1.ep-1 0x1.1p0 x 0x1p8 0x1p16 50000 181 0x1.ep-1 0x1.1p0 x -0x1p8 -0x1p16 50000 182' 183 184range_sin=' 185 0 0x1p23 500000 186 -0 -0x1p23 500000 187 0x1p23 inf 10000 188 -0x1p23 -inf 10000 189' 190range_cos="$range_sin" 191 192range_expf=' 193 0 0xffff0000 10000 194 0x1p-14 0x1p8 500000 195 -0x1p-14 -0x1p8 500000 196' 197 198range_expf_1u="$range_expf" 199range_exp2f="$range_expf" 200range_exp2f_1u="$range_expf" 201 202range_logf=' 203 0 0xffff0000 10000 204 0x1p-4 0x1p4 500000 205' 206 207range_sinf=' 208 0 0x1p20 500000 209 -0 -0x1p20 500000 210 0x1p20 inf 10000 211 -0x1p20 -inf 10000 212' 213range_cosf="$range_sinf" 214 215range_powf=' 216 0x1p-1 0x1p1 x 0x1p-7 0x1p7 50000 217 0x1p-1 0x1p1 x -0x1p-7 -0x1p7 50000 218 0x1p-70 0x1p70 x 0x1p-1 0x1p1 50000 219 0x1p-70 0x1p70 x -0x1p-1 -0x1p1 50000 220 0x1.ep-1 0x1.1p0 x 0x1p8 0x1p14 50000 221 0x1.ep-1 0x1.1p0 x -0x1p8 -0x1p14 50000 222' 223 224# error limits 225L_exp=1.9 226L_log=1.2 227L_pow=0.05 228L_sin=3.0 229L_cos=3.0 230L_expf=1.49 231L_expf_1u=0.4 232L_exp2f=1.49 233L_exp2f_1u=0.4 234L_logf=2.9 235L_sinf=1.4 236L_cosf=1.4 237L_powf=2.1 238 239while read G F D 240do 241 case "$G" in \#*) continue ;; esac 242 eval range="\${range_$G}" 243 eval L="\${L_$G}" 244 while read X 245 do 246 [ -n "$X" ] || continue 247 case "$X" in \#*) continue ;; esac 248 disable_fenv="" 249 if [ -z "$WANT_SIMD_EXCEPT" ] || [ $WANT_SIMD_EXCEPT -eq 0 ]; then 250 # If library was built with SIMD exceptions 251 # disabled, disable fenv checking in ulp 252 # tool. Otherwise, fenv checking may still be 253 # disabled by adding -f to the end of the run 254 # line. 255 disable_fenv="-f" 256 fi 257 t $D $disable_fenv $F $X 258 done << EOF 259$range 260 261EOF 262done << EOF 263# group symbol run 264exp _ZGVnN2v_exp 265log _ZGVnN2v_log 266pow _ZGVnN2vv_pow -f 267sin _ZGVnN2v_sin -z 268cos _ZGVnN2v_cos 269expf _ZGVnN4v_expf 270expf_1u _ZGVnN4v_expf_1u -f 271exp2f _ZGVnN4v_exp2f 272exp2f_1u _ZGVnN4v_exp2f_1u -f 273logf _ZGVnN4v_logf 274sinf _ZGVnN4v_sinf -z 275cosf _ZGVnN4v_cosf 276powf _ZGVnN4vv_powf -f 277EOF 278 279[ 0 -eq $FAIL ] || { 280 echo "FAILED $FAIL PASSED $PASS" 281 exit 1 282} 283