1#!/bin/bash 2 3# ULP error check script. 4# 5# Copyright (c) 2019, 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=0.01 76t expf 0 0xffff0000 10000 77t expf 0x1p-14 0x1p8 50000 78t expf -0x1p-14 -0x1p8 50000 79 80L=0.01 81t exp2f 0 0xffff0000 10000 82t exp2f 0x1p-14 0x1p8 50000 83t exp2f -0x1p-14 -0x1p8 50000 84 85L=0.32 86t logf 0 0xffff0000 10000 87t logf 0x1p-4 0x1p4 50000 88t logf 0 inf 50000 89 90L=0.26 91t log2f 0 0xffff0000 10000 92t log2f 0x1p-4 0x1p4 50000 93t log2f 0 inf 50000 94 95L=0.06 96t sinf 0 0xffff0000 10000 97t sinf 0x1p-14 0x1p54 50000 98t sinf -0x1p-14 -0x1p54 50000 99 100L=0.06 101t cosf 0 0xffff0000 10000 102t cosf 0x1p-14 0x1p54 50000 103t cosf -0x1p-14 -0x1p54 50000 104 105L=0.06 106t sincosf_sinf 0 0xffff0000 10000 107t sincosf_sinf 0x1p-14 0x1p54 50000 108t sincosf_sinf -0x1p-14 -0x1p54 50000 109 110L=0.06 111t sincosf_cosf 0 0xffff0000 10000 112t sincosf_cosf 0x1p-14 0x1p54 50000 113t sincosf_cosf -0x1p-14 -0x1p54 50000 114 115L=0.4 116t powf 0x1p-1 0x1p1 x 0x1p-7 0x1p7 50000 117t powf 0x1p-1 0x1p1 x -0x1p-7 -0x1p7 50000 118t powf 0x1p-70 0x1p70 x 0x1p-1 0x1p1 50000 119t powf 0x1p-70 0x1p70 x -0x1p-1 -0x1p1 50000 120t powf 0x1.ep-1 0x1.1p0 x 0x1p8 0x1p14 50000 121t powf 0x1.ep-1 0x1.1p0 x -0x1p8 -0x1p14 50000 122done 123 124# vector functions 125Ldir=0.5 126r='n' 127flags="${ULPFLAGS:--q} -f" 128runs= 129check __s_exp 1 && runs=1 130runv= 131check __v_exp 1 && runv=1 132runvn= 133check __vn_exp 1 && runvn=1 134 135range_exp=' 136 0 0xffff000000000000 10000 137 0x1p-6 0x1p6 400000 138 -0x1p-6 -0x1p6 400000 139 633.3 733.3 10000 140 -633.3 -777.3 10000 141' 142 143range_log=' 144 0 0xffff000000000000 10000 145 0x1p-4 0x1p4 400000 146 0 inf 400000 147' 148 149range_pow=' 150 0x1p-1 0x1p1 x 0x1p-10 0x1p10 50000 151 0x1p-1 0x1p1 x -0x1p-10 -0x1p10 50000 152 0x1p-500 0x1p500 x 0x1p-1 0x1p1 50000 153 0x1p-500 0x1p500 x -0x1p-1 -0x1p1 50000 154 0x1.ep-1 0x1.1p0 x 0x1p8 0x1p16 50000 155 0x1.ep-1 0x1.1p0 x -0x1p8 -0x1p16 50000 156' 157 158range_sin=' 159 0 0xffff000000000000 10000 160 0x1p-4 0x1p4 400000 161 -0x1p-23 0x1p23 400000 162' 163range_cos="$range_sin" 164 165range_expf=' 166 0 0xffff0000 10000 167 0x1p-14 0x1p8 500000 168 -0x1p-14 -0x1p8 500000 169' 170 171range_expf_1u="$range_expf" 172range_exp2f="$range_expf" 173range_exp2f_1u="$range_expf" 174 175range_logf=' 176 0 0xffff0000 10000 177 0x1p-4 0x1p4 500000 178' 179 180range_sinf=' 181 0 0xffff0000 10000 182 0x1p-4 0x1p4 300000 183-0x1p-9 -0x1p9 300000 184' 185range_cosf="$range_sinf" 186 187range_powf=' 188 0x1p-1 0x1p1 x 0x1p-7 0x1p7 50000 189 0x1p-1 0x1p1 x -0x1p-7 -0x1p7 50000 190 0x1p-70 0x1p70 x 0x1p-1 0x1p1 50000 191 0x1p-70 0x1p70 x -0x1p-1 -0x1p1 50000 192 0x1.ep-1 0x1.1p0 x 0x1p8 0x1p14 50000 193 0x1.ep-1 0x1.1p0 x -0x1p8 -0x1p14 50000 194' 195 196# error limits 197L_exp=1.9 198L_log=1.2 199L_pow=0.05 200L_sin=3.0 201L_cos=3.0 202L_expf=1.49 203L_expf_1u=0.4 204L_exp2f=1.49 205L_exp2f_1u=0.4 206L_logf=2.9 207L_sinf=1.4 208L_cosf=1.4 209L_powf=2.1 210 211while read G F R 212do 213 [ "$R" = 1 ] || continue 214 case "$G" in \#*) continue ;; esac 215 eval range="\${range_$G}" 216 eval L="\${L_$G}" 217 while read X 218 do 219 [ -n "$X" ] || continue 220 case "$X" in \#*) continue ;; esac 221 t $F $X 222 done << EOF 223$range 224EOF 225done << EOF 226# group symbol run 227exp __s_exp $runs 228exp __v_exp $runv 229exp __vn_exp $runvn 230exp _ZGVnN2v_exp $runvn 231 232log __s_log $runs 233log __v_log $runv 234log __vn_log $runvn 235log _ZGVnN2v_log $runvn 236 237pow __s_pow $runs 238pow __v_pow $runv 239pow __vn_pow $runvn 240pow _ZGVnN2vv_pow $runvn 241 242sin __s_sin $runs 243sin __v_sin $runv 244sin __vn_sin $runvn 245sin _ZGVnN2v_sin $runvn 246 247cos __s_cos $runs 248cos __v_cos $runv 249cos __vn_cos $runvn 250cos _ZGVnN2v_cos $runvn 251 252expf __s_expf $runs 253expf __v_expf $runv 254expf __vn_expf $runvn 255expf _ZGVnN4v_expf $runvn 256 257expf_1u __s_expf_1u $runs 258expf_1u __v_expf_1u $runv 259expf_1u __vn_expf_1u $runvn 260 261exp2f __s_exp2f $runs 262exp2f __v_exp2f $runv 263exp2f __vn_exp2f $runvn 264exp2f _ZGVnN4v_exp2f $runvn 265 266exp2f_1u __s_exp2f_1u $runs 267exp2f_1u __v_exp2f_1u $runv 268exp2f_1u __vn_exp2f_1u $runvn 269 270logf __s_logf $runs 271logf __v_logf $runv 272logf __vn_logf $runvn 273logf _ZGVnN4v_logf $runvn 274 275sinf __s_sinf $runs 276sinf __v_sinf $runv 277sinf __vn_sinf $runvn 278sinf _ZGVnN4v_sinf $runvn 279 280cosf __s_cosf $runs 281cosf __v_cosf $runv 282cosf __vn_cosf $runvn 283cosf _ZGVnN4v_cosf $runvn 284 285powf __s_powf $runs 286powf __v_powf $runv 287powf __vn_powf $runvn 288powf _ZGVnN4vv_powf $runvn 289EOF 290 291[ 0 -eq $FAIL ] || { 292 echo "FAILED $FAIL PASSED $PASS" 293 exit 1 294} 295