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