aboutsummaryrefslogtreecommitdiff
path: root/math/test
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2019-08-09 15:39:09 +0100
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2019-10-14 11:58:53 +0100
commitc5cba8528da13fe0d647dbd0f80d0cf21434b224 (patch)
treefe2dfbc6732ee358a011073e39adf4d36c71a86a /math/test
parentc280e49d7b1d1987e75de0e0e57a63ee7167ad5f (diff)
downloadarm-optimized-routines-c5cba8528da13fe0d647dbd0f80d0cf21434b224.tar.gz
Add vector sinf and cosf
The polynomials were produced by searching the coefficient space using heuristics and ideas from https://arxiv.org/abs/1508.03211 The worst-case error is 1.886 ulp, large inputs (> 2^20) and other special cases use scalar sinf and cosf.
Diffstat (limited to 'math/test')
-rw-r--r--math/test/mathbench.c8
-rwxr-xr-xmath/test/runulp.sh19
-rw-r--r--math/test/ulp.c14
3 files changed, 41 insertions, 0 deletions
diff --git a/math/test/mathbench.c b/math/test/mathbench.c
index e4d4a8b..7544a7e 100644
--- a/math/test/mathbench.c
+++ b/math/test/mathbench.c
@@ -216,12 +216,14 @@ F (sinf, -3.1, 3.1)
F (sinf, 3.3, 33.3)
F (sinf, 100, 1000)
F (sinf, 1e6, 1e32)
+F (__s_sinf, -3.1, 3.1)
F (cosf, 0.1, 0.7)
F (cosf, 0.8, 3.1)
F (cosf, -3.1, 3.1)
F (cosf, 3.3, 33.3)
F (cosf, 100, 1000)
F (cosf, 1e6, 1e32)
+F (__s_cosf, -3.1, 3.1)
#if __aarch64__
VD (__v_dummy, 1.0, 2.0)
VD (__v_exp, -9.9, 9.9)
@@ -229,6 +231,8 @@ VF (__v_dummyf, 1.0, 2.0)
VF (__v_expf, -9.9, 9.9)
VF (__v_expf_1u, -9.9, 9.9)
VF (__v_logf, 0.01, 11.1)
+VF (__v_sinf, -3.1, 3.1)
+VF (__v_cosf, -3.1, 3.1)
#ifdef __vpcs
VND (__vn_dummy, 1.0, 2.0)
VND (__vn_exp, -9.9, 9.9)
@@ -239,6 +243,10 @@ VNF (_ZGVnN4v_expf, -9.9, 9.9)
VNF (__vn_expf_1u, -9.9, 9.9)
VNF (__vn_logf, 0.01, 11.1)
VNF (_ZGVnN4v_logf, 0.01, 11.1)
+VNF (__vn_sinf, -3.1, 3.1)
+VNF (_ZGVnN4v_sinf, -3.1, 3.1)
+VNF (__vn_cosf, -3.1, 3.1)
+VNF (_ZGVnN4v_cosf, -3.1, 3.1)
#endif
#endif
{0},
diff --git a/math/test/runulp.sh b/math/test/runulp.sh
index 81716fa..efa9269 100755
--- a/math/test/runulp.sh
+++ b/math/test/runulp.sh
@@ -121,11 +121,20 @@ range_logf='
0x1p-4 0x1p4 500000
'
+range_sinf='
+ 0 0xffff0000 10000
+ 0x1p-4 0x1p4 300000
+-0x1p-9 -0x1p9 300000
+'
+range_cosf="$range_sinf"
+
# error limits
L_exp=1.9
L_expf=1.49
L_expf_1u=0.4
L_logf=2.9
+L_sinf=1.4
+L_cosf=1.4
# group symbol run
echo "
@@ -148,6 +157,16 @@ logf __v_logf $runv
logf __vn_logf $runvn
logf _ZGVnN4v_logf $runvn
+sinf __s_sinf 1
+sinf __v_sinf $runv
+sinf __vn_sinf $runvn
+sinf _ZGVnN4v_sinf $runvn
+
+cosf __s_cosf 1
+cosf __v_cosf $runv
+cosf __vn_cosf $runvn
+cosf _ZGVnN4v_cosf $runvn
+
" | while read G F R
do
[ "$R" = 1 ] || continue
diff --git a/math/test/ulp.c b/math/test/ulp.c
index 2ffba9b..4eb9d85 100644
--- a/math/test/ulp.c
+++ b/math/test/ulp.c
@@ -223,15 +223,21 @@ static const double dv[2] = {1.0, -INFINITY};
static inline v_float argf(float x) { return (v_float){x,x,x,fv[secondcall]}; }
static inline v_double argd(double x) { return (v_double){x,dv[secondcall]}; }
+static float v_sinf(float x) { return __v_sinf(argf(x))[0]; }
+static float v_cosf(float x) { return __v_cosf(argf(x))[0]; }
static float v_expf_1u(float x) { return __v_expf_1u(argf(x))[0]; }
static float v_expf(float x) { return __v_expf(argf(x))[0]; }
static float v_logf(float x) { return __v_logf(argf(x))[0]; }
static double v_exp(double x) { return __v_exp(argd(x))[0]; }
#ifdef __vpcs
+static float vn_sinf(float x) { return __vn_sinf(argf(x))[0]; }
+static float vn_cosf(float x) { return __vn_cosf(argf(x))[0]; }
static float vn_expf_1u(float x) { return __vn_expf_1u(argf(x))[0]; }
static float vn_expf(float x) { return __vn_expf(argf(x))[0]; }
static float vn_logf(float x) { return __vn_logf(argf(x))[0]; }
static double vn_exp(double x) { return __vn_exp(argd(x))[0]; }
+static float Z_sinf(float x) { return _ZGVnN4v_sinf(argf(x))[0]; }
+static float Z_cosf(float x) { return _ZGVnN4v_cosf(argf(x))[0]; }
static float Z_expf(float x) { return _ZGVnN4v_expf(argf(x))[0]; }
static float Z_logf(float x) { return _ZGVnN4v_logf(argf(x))[0]; }
static double Z_exp(double x) { return _ZGVnN2v_exp(argd(x))[0]; }
@@ -293,20 +299,28 @@ static const struct fun fun[] = {
D1 (log)
D1 (log2)
D2 (pow)
+ F (__s_sinf, __s_sinf, sin, mpfr_sin, 1, 1, f1, 0)
+ F (__s_cosf, __s_cosf, cos, mpfr_cos, 1, 1, f1, 0)
F (__s_expf_1u, __s_expf_1u, exp, mpfr_exp, 1, 1, f1, 0)
F (__s_expf, __s_expf, exp, mpfr_exp, 1, 1, f1, 0)
F (__s_logf, __s_logf, log, mpfr_log, 1, 1, f1, 0)
F (__s_exp, __s_exp, expl, mpfr_exp, 1, 0, d1, 0)
#if __aarch64__
+ F (__v_sinf, v_sinf, sin, mpfr_sin, 1, 1, f1, 1)
+ F (__v_cosf, v_cosf, cos, mpfr_cos, 1, 1, f1, 1)
F (__v_expf_1u, v_expf_1u, exp, mpfr_exp, 1, 1, f1, 1)
F (__v_expf, v_expf, exp, mpfr_exp, 1, 1, f1, 1)
F (__v_logf, v_logf, log, mpfr_log, 1, 1, f1, 1)
F (__v_exp, v_exp, expl, mpfr_exp, 1, 0, d1, 1)
#ifdef __vpcs
+ F (__vn_sinf, vn_sinf, sin, mpfr_sin, 1, 1, f1, 1)
+ F (__vn_cosf, vn_cosf, cos, mpfr_cos, 1, 1, f1, 1)
F (__vn_expf_1u, vn_expf_1u, exp, mpfr_exp, 1, 1, f1, 1)
F (__vn_expf, vn_expf, exp, mpfr_exp, 1, 1, f1, 1)
F (__vn_logf, vn_logf, log, mpfr_log, 1, 1, f1, 1)
F (__vn_exp, vn_exp, expl, mpfr_exp, 1, 0, d1, 1)
+ F (_ZGVnN4v_sinf, Z_sinf, sin, mpfr_sin, 1, 1, f1, 1)
+ F (_ZGVnN4v_cosf, Z_cosf, cos, mpfr_cos, 1, 1, f1, 1)
F (_ZGVnN4v_expf, Z_expf, exp, mpfr_exp, 1, 1, f1, 1)
F (_ZGVnN4v_logf, Z_logf, log, mpfr_log, 1, 1, f1, 1)
F (_ZGVnN2v_exp, Z_exp, expl, mpfr_exp, 1, 0, d1, 1)