aboutsummaryrefslogtreecommitdiff
path: root/math/test/runulp.sh
diff options
context:
space:
mode:
authorAndrew Turner <andrew@FreeBSD.org>2025-01-10 10:34:52 +0000
committerAndrew Turner <andrew@FreeBSD.org>2025-01-10 10:39:34 +0000
commit9d1de25930735261c16ed874a933b4c1f1d9041e (patch)
treeb0cac1c933cc1ecb885c7e757b89ffbf13f1f012 /math/test/runulp.sh
parentedc5c0de794f521eb620d2b6cbaee2434442a8f3 (diff)
Import the v25.01 release of the Arm Optimized Routines [1]. [1] https://github.com/ARM-software/optimized-routines/tree/v25.01 Sponsored by: Arm Ltd
Diffstat (limited to 'math/test/runulp.sh')
-rwxr-xr-xmath/test/runulp.sh311
1 files changed, 67 insertions, 244 deletions
diff --git a/math/test/runulp.sh b/math/test/runulp.sh
index e2e03e3ae761..672908f355c4 100755
--- a/math/test/runulp.sh
+++ b/math/test/runulp.sh
@@ -2,7 +2,7 @@
# ULP error check script.
#
-# Copyright (c) 2019-2023, Arm Limited.
+# Copyright (c) 2019-2024, Arm Limited.
# SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
#set -x
@@ -20,260 +20,83 @@ FAIL=0
PASS=0
t() {
- [ $r = "n" ] && Lt=$L || Lt=$Ldir
- $emu ./ulp -r $r -e $Lt $flags "$@" && PASS=$((PASS+1)) || FAIL=$((FAIL+1))
+ # First argument: routine name
+ routine=$1; shift
+ # Second and third argument: lo and hi bounds
+ # Extra processing needed for bivariate routines
+ IFS=',' read -ra LO <<< "$1"; shift
+ IFS=',' read -ra HI <<< "$1"; shift
+ ITV="${LO[0]} ${HI[0]}"
+ for i in "${!LO[@]}"; do
+ [[ "$i" -eq "0" ]] || ITV="$ITV x ${LO[$i]} ${HI[$i]}"
+ done
+ # Fourth argument: number of test points
+ n=$1; shift
+ # Any remaining arguments forwards directly to ulp tool
+ extra_flags="$@"
+
+ # Read ULP limits, fenv expectation and control values from autogenerated files
+ limits_file=$LIMITS
+ [ $r == "n" ] || limits_file=${limits_file}_nn
+ L=$(grep "^$routine " $limits_file | awk '{print $2}')
+ [ -n "$L" ] || { echo ERROR: Could not determine ULP limit for $routine in $limits_file && false; }
+ cvals=($(grep "^$routine " $CVALS | awk '{print $2}'))
+
+ if grep -q "^$routine$" $DISABLE_FENV; then extra_flags="$extra_flags -f"; fi
+ # Emulate a do-while loop to loop over cvals, but still execute once if it is empty
+ while : ; do
+ # Empty string if we are at the end of cvals array
+ c_arg=""
+ [ -z "${cvals[0]:-}" ] || c_arg="-c ${cvals[0]}"
+ $emu ./ulp -e $L $flags $extra_flags -r $r $c_arg $routine $ITV $n && PASS=$((PASS+1)) || FAIL=$((FAIL+1))
+ # Shift cvals by 1, and break if it is now empty
+ cvals=("${cvals[@]:1}")
+ [ -n "${cvals[0]:-}" ] || break
+ done
+
+ # Run ULP tool
+
}
check() {
- $emu ./ulp -f -q "$@" >/dev/null
+ $emu ./ulp -f -q "$@"
}
-Ldir=0.5
+if [[ $WANT_EXPERIMENTAL_MATH -eq 1 ]] && [[ $WANT_SVE_TESTS -eq 1 ]] && [[ $USE_MPFR -eq 0 ]]; then
+ # No guarantees about powi accuracy, so regression-test for exactness
+ # w.r.t. the custom reference impl in ulp_wrappers.h
+ if [ -z "$FUNC" ] || [ "$FUNC" == "_ZGVsMxvv_powi" ]; then
+ check -q -f -e 0 _ZGVsMxvv_powi 0 inf x 0 1000 100000
+ check -q -f -e 0 _ZGVsMxvv_powi -0 -inf x 0 1000 100000
+ check -q -f -e 0 _ZGVsMxvv_powi 0 inf x -0 -1000 100000
+ check -q -f -e 0 _ZGVsMxvv_powi -0 -inf x -0 -1000 100000
+ fi
+ if [ -z "$FUNC" ] || [ "$FUNC" == "_ZGVsMxvv_powk" ]; then
+ check -q -f -e 0 _ZGVsMxvv_powk 0 inf x 0 1000 100000
+ check -q -f -e 0 _ZGVsMxvv_powk -0 -inf x 0 1000 100000
+ check -q -f -e 0 _ZGVsMxvv_powk 0 inf x -0 -1000 100000
+ check -q -f -e 0 _ZGVsMxvv_powk -0 -inf x -0 -1000 100000
+ fi
+fi
+
+# Test generic routines in all rounding modes
for r in $rmodes
do
-L=0.01
-t exp 0 0xffff000000000000 10000
-t exp 0x1p-6 0x1p6 40000
-t exp -0x1p-6 -0x1p6 40000
-t exp 633.3 733.3 10000
-t exp -633.3 -777.3 10000
-
-L=0.01
-t exp2 0 0xffff000000000000 10000
-t exp2 0x1p-6 0x1p6 40000
-t exp2 -0x1p-6 -0x1p6 40000
-t exp2 633.3 733.3 10000
-t exp2 -633.3 -777.3 10000
-
-L=0.02
-t log 0 0xffff000000000000 10000
-t log 0x1p-4 0x1p4 40000
-t log 0 inf 40000
-
-L=0.05
-t log2 0 0xffff000000000000 10000
-t log2 0x1p-4 0x1p4 40000
-t log2 0 inf 40000
-
-L=0.05
-t pow 0.5 2.0 x 0 inf 20000
-t pow -0.5 -2.0 x 0 inf 20000
-t pow 0.5 2.0 x -0 -inf 20000
-t pow -0.5 -2.0 x -0 -inf 20000
-t pow 0.5 2.0 x 0x1p-10 0x1p10 40000
-t pow 0.5 2.0 x -0x1p-10 -0x1p10 40000
-t pow 0 inf x 0.5 2.0 80000
-t pow 0 inf x -0.5 -2.0 80000
-t pow 0x1.fp-1 0x1.08p0 x 0x1p8 0x1p17 80000
-t pow 0x1.fp-1 0x1.08p0 x -0x1p8 -0x1p17 80000
-t pow 0 0x1p-1000 x 0 1.0 50000
-t pow 0x1p1000 inf x 0 1.0 50000
-t pow 0x1.ffffffffffff0p-1 0x1.0000000000008p0 x 0x1p60 0x1p68 50000
-t pow 0x1.ffffffffff000p-1 0x1p0 x 0x1p50 0x1p52 50000
-t pow -0x1.ffffffffff000p-1 -0x1p0 x 0x1p50 0x1p52 50000
-
-L=0.02
-t exp10 0 0x1p-47 5000
-t exp10 -0 -0x1p-47 5000
-t exp10 0x1p-47 1 50000
-t exp10 -0x1p-47 -1 50000
-t exp10 1 0x1.34413509f79ffp8 50000
-t exp10 -1 -0x1.434e6420f4374p8 50000
-t exp10 0x1.34413509f79ffp8 inf 5000
-t exp10 -0x1.434e6420f4374p8 -inf 5000
-
-L=1.0
-Ldir=0.9
-t erf 0 0xffff000000000000 10000
-t erf 0x1p-1022 0x1p-26 40000
-t erf -0x1p-1022 -0x1p-26 40000
-t erf 0x1p-26 0x1p3 40000
-t erf -0x1p-26 -0x1p3 40000
-t erf 0 inf 40000
-Ldir=0.5
-
-L=0.01
-t expf 0 0xffff0000 10000
-t expf 0x1p-14 0x1p8 50000
-t expf -0x1p-14 -0x1p8 50000
-
-L=0.01
-t exp2f 0 0xffff0000 10000
-t exp2f 0x1p-14 0x1p8 50000
-t exp2f -0x1p-14 -0x1p8 50000
-
-L=0.32
-t logf 0 0xffff0000 10000
-t logf 0x1p-4 0x1p4 50000
-t logf 0 inf 50000
-
-L=0.26
-t log2f 0 0xffff0000 10000
-t log2f 0x1p-4 0x1p4 50000
-t log2f 0 inf 50000
-
-L=0.06
-t sinf 0 0xffff0000 10000
-t sinf 0x1p-14 0x1p54 50000
-t sinf -0x1p-14 -0x1p54 50000
-
-L=0.06
-t cosf 0 0xffff0000 10000
-t cosf 0x1p-14 0x1p54 50000
-t cosf -0x1p-14 -0x1p54 50000
-
-L=0.06
-t sincosf_sinf 0 0xffff0000 10000
-t sincosf_sinf 0x1p-14 0x1p54 50000
-t sincosf_sinf -0x1p-14 -0x1p54 50000
-
-L=0.06
-t sincosf_cosf 0 0xffff0000 10000
-t sincosf_cosf 0x1p-14 0x1p54 50000
-t sincosf_cosf -0x1p-14 -0x1p54 50000
-
-L=0.4
-t powf 0x1p-1 0x1p1 x 0x1p-7 0x1p7 50000
-t powf 0x1p-1 0x1p1 x -0x1p-7 -0x1p7 50000
-t powf 0x1p-70 0x1p70 x 0x1p-1 0x1p1 50000
-t powf 0x1p-70 0x1p70 x -0x1p-1 -0x1p1 50000
-t powf 0x1.ep-1 0x1.1p0 x 0x1p8 0x1p14 50000
-t powf 0x1.ep-1 0x1.1p0 x -0x1p8 -0x1p14 50000
-
-L=0.6
-Ldir=0.9
-t erff 0 0xffff0000 10000
-t erff 0x1p-127 0x1p-26 40000
-t erff -0x1p-127 -0x1p-26 40000
-t erff 0x1p-26 0x1p3 40000
-t erff -0x1p-26 -0x1p3 40000
-t erff 0 inf 40000
-Ldir=0.5
-
+ while read F LO HI N
+ do
+ [[ -z $F ]] || t $F $LO $HI $N
+ done << EOF
+$(grep "\b$FUNC\b" $GEN_ITVS)
+EOF
done
-# vector functions
-
-Ldir=0.5
-r='n'
-flags="${ULPFLAGS:--q}"
-
-range_exp='
- 0 0xffff000000000000 10000
- 0x1p-6 0x1p6 400000
- -0x1p-6 -0x1p6 400000
- 633.3 733.3 10000
- -633.3 -777.3 10000
-'
-
-range_log='
- 0 0xffff000000000000 10000
- 0x1p-4 0x1p4 400000
- 0 inf 400000
-'
-
-range_pow='
- 0x1p-1 0x1p1 x 0x1p-10 0x1p10 50000
- 0x1p-1 0x1p1 x -0x1p-10 -0x1p10 50000
- 0x1p-500 0x1p500 x 0x1p-1 0x1p1 50000
- 0x1p-500 0x1p500 x -0x1p-1 -0x1p1 50000
- 0x1.ep-1 0x1.1p0 x 0x1p8 0x1p16 50000
- 0x1.ep-1 0x1.1p0 x -0x1p8 -0x1p16 50000
-'
-
-range_sin='
- 0 0x1p23 500000
- -0 -0x1p23 500000
- 0x1p23 inf 10000
- -0x1p23 -inf 10000
-'
-range_cos="$range_sin"
-
-range_expf='
- 0 0xffff0000 10000
- 0x1p-14 0x1p8 500000
- -0x1p-14 -0x1p8 500000
-'
-
-range_expf_1u="$range_expf"
-range_exp2f="$range_expf"
-range_exp2f_1u="$range_expf"
-
-range_logf='
- 0 0xffff0000 10000
- 0x1p-4 0x1p4 500000
-'
-
-range_sinf='
- 0 0x1p20 500000
- -0 -0x1p20 500000
- 0x1p20 inf 10000
- -0x1p20 -inf 10000
-'
-range_cosf="$range_sinf"
-
-range_powf='
- 0x1p-1 0x1p1 x 0x1p-7 0x1p7 50000
- 0x1p-1 0x1p1 x -0x1p-7 -0x1p7 50000
- 0x1p-70 0x1p70 x 0x1p-1 0x1p1 50000
- 0x1p-70 0x1p70 x -0x1p-1 -0x1p1 50000
- 0x1.ep-1 0x1.1p0 x 0x1p8 0x1p14 50000
- 0x1.ep-1 0x1.1p0 x -0x1p8 -0x1p14 50000
-'
-
-# error limits
-L_exp=1.9
-L_log=1.2
-L_pow=0.05
-L_sin=3.0
-L_cos=3.0
-L_expf=1.49
-L_expf_1u=0.4
-L_exp2f=1.49
-L_exp2f_1u=0.4
-L_logf=2.9
-L_sinf=1.4
-L_cosf=1.4
-L_powf=2.1
-
-while read G F D
+# Only test arch-specific routines in round-to-nearest, with sign of zero ignored (-z flag)
+r=n
+while read F LO HI N
do
- case "$G" in \#*) continue ;; esac
- eval range="\${range_$G}"
- eval L="\${L_$G}"
- while read X
- do
- [ -n "$X" ] || continue
- case "$X" in \#*) continue ;; esac
- disable_fenv=""
- if [ -z "$WANT_SIMD_EXCEPT" ] || [ $WANT_SIMD_EXCEPT -eq 0 ]; then
- # If library was built with SIMD exceptions
- # disabled, disable fenv checking in ulp
- # tool. Otherwise, fenv checking may still be
- # disabled by adding -f to the end of the run
- # line.
- disable_fenv="-f"
- fi
- t $D $disable_fenv $F $X
- done << EOF
-$range
-
-EOF
+ [[ -z $F ]] || t $F $LO $HI $N -z
done << EOF
-# group symbol run
-exp _ZGVnN2v_exp
-log _ZGVnN2v_log
-pow _ZGVnN2vv_pow -f
-sin _ZGVnN2v_sin -z
-cos _ZGVnN2v_cos
-expf _ZGVnN4v_expf
-expf_1u _ZGVnN4v_expf_1u -f
-exp2f _ZGVnN4v_exp2f
-exp2f_1u _ZGVnN4v_exp2f_1u -f
-logf _ZGVnN4v_logf
-sinf _ZGVnN4v_sinf -z
-cosf _ZGVnN4v_cosf
-powf _ZGVnN4vv_powf -f
+$(grep "\b$FUNC\b" $ARCH_ITVS)
EOF
[ 0 -eq $FAIL ] || {