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 14flags="${ULPFLAGS:--q}" 15emu="$@" 16 17# Enable SVE testing 18WANT_SVE_MATH=${WANT_SVE_MATH:-0} 19 20FAIL=0 21PASS=0 22 23t() { 24 key=$(cat $ALIASES | { grep " $1$" || echo $1; } | awk '{print $1}') 25 L=$(cat $LIMITS | grep "^$key " | awk '{print $2}') 26 [[ $L =~ ^[0-9]+\.[0-9]+$ ]] 27 extra_flags="" 28 [[ -z "${5:-}" ]] || extra_flags="$extra_flags -c $5" 29 grep -q "^$key$" $FENV || extra_flags="$extra_flags -f" 30 $emu ./ulp -e $L $flags ${extra_flags} $1 $2 $3 $4 && PASS=$((PASS+1)) || FAIL=$((FAIL+1)) 31} 32 33check() { 34 $emu ./ulp -f -q "$@" #>/dev/null 35} 36 37# Regression-test for correct NaN handling in atan2 38check atan2 0x1p-1022 0x1p-1000 x 0 0x1p-1022 40000 39check atan2 0x1.7887a0a717aefp+1017 0x1.7887a0a717aefp+1017 x -nan -nan 40check atan2 nan nan x -nan -nan 41 42# vector functions 43flags="${ULPFLAGS:--q}" 44runs= 45check __s_log10f 1 && runs=1 46runv= 47check __v_log10f 1 && runv=1 48runvn= 49check __vn_log10f 1 && runvn=1 50runsv= 51if [ $WANT_SVE_MATH -eq 1 ]; then 52check __sv_cosf 0 && runsv=1 53check __sv_cos 0 && runsv=1 54check __sv_sinf 0 && runsv=1 55check __sv_sin 0 && runsv=1 56# No guarantees about powi accuracy, so regression-test for exactness 57# w.r.t. the custom reference impl in ulp_wrappers.h 58check -q -f -e 0 __sv_powif 0 inf x 0 1000 100000 && runsv=1 59check -q -f -e 0 __sv_powif -0 -inf x 0 1000 100000 && runsv=1 60check -q -f -e 0 __sv_powif 0 inf x -0 -1000 100000 && runsv=1 61check -q -f -e 0 __sv_powif -0 -inf x -0 -1000 100000 && runsv=1 62check -q -f -e 0 __sv_powi 0 inf x 0 1000 100000 && runsv=1 63check -q -f -e 0 __sv_powi -0 -inf x 0 1000 100000 && runsv=1 64check -q -f -e 0 __sv_powi 0 inf x -0 -1000 100000 && runsv=1 65check -q -f -e 0 __sv_powi -0 -inf x -0 -1000 100000 && runsv=1 66fi 67 68while read F LO HI N C 69do 70 t $F $LO $HI $N $C 71done << EOF 72$(cat $INTERVALS) 73EOF 74 75[ 0 -eq $FAIL ] || { 76 echo "FAILED $FAIL PASSED $PASS" 77 exit 1 78} 79