From 1f3b16380154f854d7f0a0e00e2d8899b7ee1a19 Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Wed, 6 Nov 2019 19:41:30 +0000 Subject: math: add WANT_VMATH feature macro When defined as 0 the vector math code is not built and not tested. --- math/test/mathbench.c | 45 +++++++++++++++++++++++++++------------------ math/test/runulp.sh | 20 +++++++++++--------- math/test/ulp.c | 9 ++++++++- math/v_exp.h | 2 ++ math/v_exp_data.c | 2 ++ math/v_log.h | 2 ++ math/v_log_data.c | 2 ++ math/v_math.h | 7 +++++++ 8 files changed, 61 insertions(+), 28 deletions(-) (limited to 'math') diff --git a/math/test/mathbench.c b/math/test/mathbench.c index 3152de8..8d3ff1d 100644 --- a/math/test/mathbench.c +++ b/math/test/mathbench.c @@ -15,6 +15,11 @@ #include #include "mathlib.h" +#ifndef WANT_VMATH +/* Enable the build of vector math code. */ +# define WANT_VMATH 1 +#endif + /* Number of measurements, best result is reported. */ #define MEASURE 60 /* Array size. */ @@ -29,7 +34,7 @@ static float Af[N]; static long measurecount = MEASURE; static long itercount = ITER; -#if __aarch64__ +#if __aarch64__ && WANT_VMATH typedef __f64x2_t v_double; #define v_double_len() 2 @@ -85,6 +90,7 @@ dummyf (float x) return x; } +#if WANT_VMATH #if __aarch64__ static v_double __v_dummy (v_double x) @@ -131,6 +137,13 @@ xy__v_powf (v_float x) } #endif +static float +xy__s_powf (float x) +{ + return __s_powf (x, x); +} +#endif + static double xypow (double x) { @@ -143,12 +156,6 @@ xypowf (float x) return powf (x, x); } -static float -xy__s_powf (float x) -{ - return __s_powf (x, x); -} - static double xpow (double x) { @@ -207,15 +214,11 @@ static const struct fun #define VND(func, lo, hi) {#func, 'd', 'n', lo, hi, {.vnd = func}}, #define VNF(func, lo, hi) {#func, 'f', 'n', lo, hi, {.vnf = func}}, D (dummy, 1.0, 2.0) -D (__s_sin, -3.1, 3.1) -D (__s_cos, -3.1, 3.1) D (exp, -9.9, 9.9) D (exp, 0.5, 1.0) -D (__s_exp, -9.9, 9.9) D (exp2, -9.9, 9.9) D (log, 0.01, 11.1) D (log, 0.999, 1.001) -D (__s_log, 0.01, 11.1) D (log2, 0.01, 11.1) D (log2, 0.999, 1.001) {"pow", 'd', 0, 0.01, 11.1, {.d = xypow}}, @@ -224,16 +227,10 @@ D (ypow, -9.9, 9.9) F (dummyf, 1.0, 2.0) F (expf, -9.9, 9.9) -F (__s_expf, -9.9, 9.9) -F (__s_expf_1u, -9.9, 9.9) -F (__s_exp2f, -9.9, 9.9) -F (__s_exp2f_1u, -9.9, 9.9) F (exp2f, -9.9, 9.9) F (logf, 0.01, 11.1) -F (__s_logf, 0.01, 11.1) F (log2f, 0.01, 11.1) {"powf", 'f', 0, 0.01, 11.1, {.f = xypowf}}, -{"__s_powf", 'f', 0, 0.01, 11.1, {.f = xy__s_powf}}, F (xpowf, 0.01, 11.1) F (ypowf, -9.9, 9.9) {"sincosf", 'f', 0, 0.1, 0.7, {.f = sincosf_wrap}}, @@ -248,13 +245,24 @@ 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) +#if WANT_VMATH +D (__s_sin, -3.1, 3.1) +D (__s_cos, -3.1, 3.1) +D (__s_exp, -9.9, 9.9) +D (__s_log, 0.01, 11.1) +F (__s_expf, -9.9, 9.9) +F (__s_expf_1u, -9.9, 9.9) +F (__s_exp2f, -9.9, 9.9) +F (__s_exp2f_1u, -9.9, 9.9) +F (__s_logf, 0.01, 11.1) +{"__s_powf", 'f', 0, 0.01, 11.1, {.f = xy__s_powf}}, +F (__s_sinf, -3.1, 3.1) F (__s_cosf, -3.1, 3.1) #if __aarch64__ VD (__v_dummy, 1.0, 2.0) @@ -298,6 +306,7 @@ VNF (__vn_cosf, -3.1, 3.1) VNF (_ZGVnN4v_cosf, -3.1, 3.1) #endif #endif +#endif {0}, #undef F #undef D diff --git a/math/test/runulp.sh b/math/test/runulp.sh index 229757b..44393b8 100755 --- a/math/test/runulp.sh +++ b/math/test/runulp.sh @@ -95,6 +95,8 @@ done Ldir=0.5 r='n' flags="${ULPFLAGS:--q} -f" +runs= +check __s_exp 1 && runs=1 runv= check __v_exp 1 && runv=1 runvn= @@ -166,45 +168,45 @@ $range EOF done << EOF # group symbol run -exp __s_exp 1 +exp __s_exp $runs exp __v_exp $runv exp __vn_exp $runvn exp _ZGVnN2v_exp $runvn -expf __s_expf 1 +expf __s_expf $runs expf __v_expf $runv expf __vn_expf $runvn expf _ZGVnN4v_expf $runvn -expf_1u __s_expf_1u 1 +expf_1u __s_expf_1u $runs expf_1u __v_expf_1u $runv expf_1u __vn_expf_1u $runvn -exp2f __s_exp2f 1 +exp2f __s_exp2f $runs exp2f __v_exp2f $runv exp2f __vn_exp2f $runvn exp2f _ZGVnN4v_exp2f $runvn -exp2f_1u __s_exp2f_1u 1 +exp2f_1u __s_exp2f_1u $runs exp2f_1u __v_exp2f_1u $runv exp2f_1u __vn_exp2f_1u $runvn -logf __s_logf 1 +logf __s_logf $runs logf __v_logf $runv logf __vn_logf $runvn logf _ZGVnN4v_logf $runvn -sinf __s_sinf 1 +sinf __s_sinf $runs sinf __v_sinf $runv sinf __vn_sinf $runvn sinf _ZGVnN4v_sinf $runvn -cosf __s_cosf 1 +cosf __s_cosf $runs cosf __v_cosf $runv cosf __vn_cosf $runvn cosf _ZGVnN4v_cosf $runvn -powf __s_powf 1 +powf __s_powf $runs powf __v_powf $runv powf __vn_powf $runvn powf _ZGVnN4vv_powf $runvn diff --git a/math/test/ulp.c b/math/test/ulp.c index ffe3501..b746080 100644 --- a/math/test/ulp.c +++ b/math/test/ulp.c @@ -23,6 +23,11 @@ # include #endif +#ifndef WANT_VMATH +/* Enable the build of vector math code. */ +# define WANT_VMATH 1 +#endif + static inline uint64_t asuint64 (double f) { @@ -215,7 +220,7 @@ struct conf static int secondcall; /* Wrappers for vector functions. */ -#if __aarch64__ +#if __aarch64__ && WANT_VMATH typedef __f32x4_t v_float; typedef __f64x2_t v_double; static const float fv[2] = {1.0f, -INFINITY}; @@ -316,6 +321,7 @@ static const struct fun fun[] = { D1 (log) D1 (log2) D2 (pow) +#if WANT_VMATH 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) @@ -366,6 +372,7 @@ static const struct fun fun[] = { F (_ZGVnN2v_log, Z_log, logl, mpfr_log, 1, 0, d1, 1) #endif #endif +#endif #undef F #undef F1 #undef F2 diff --git a/math/v_exp.h b/math/v_exp.h index 38713d6..305da19 100644 --- a/math/v_exp.h +++ b/math/v_exp.h @@ -6,7 +6,9 @@ */ #include "v_math.h" +#if WANT_VMATH #define V_EXP_TABLE_BITS 7 extern const u64_t __v_exp_data[1 << V_EXP_TABLE_BITS] HIDDEN; +#endif diff --git a/math/v_exp_data.c b/math/v_exp_data.c index 19b2701..3653554 100644 --- a/math/v_exp_data.c +++ b/math/v_exp_data.c @@ -6,6 +6,7 @@ */ #include "v_exp.h" +#if WANT_VMATH #define N (1 << V_EXP_TABLE_BITS) @@ -399,3 +400,4 @@ const u64_t __v_exp_data[] = { 0x3feff9d96b2a23d9, #endif }; +#endif diff --git a/math/v_log.h b/math/v_log.h index d1c6fca..bcc2fa6 100644 --- a/math/v_log.h +++ b/math/v_log.h @@ -6,6 +6,7 @@ */ #include "v_math.h" +#if WANT_VMATH #define V_LOG_TABLE_BITS 7 @@ -14,3 +15,4 @@ extern const struct v_log_data f64_t invc; f64_t logc; } __v_log_data[1 << V_LOG_TABLE_BITS] HIDDEN; +#endif diff --git a/math/v_log_data.c b/math/v_log_data.c index 36fe867..97ee5b0 100644 --- a/math/v_log_data.c +++ b/math/v_log_data.c @@ -6,6 +6,7 @@ */ #include "v_log.h" +#if WANT_VMATH #define N (1 << V_LOG_TABLE_BITS) @@ -154,3 +155,4 @@ const struct v_log_data __v_log_data[N] = { {0x1.6e1ee3700cd11p-1, 0x1.57690d5744a45p-2}, {0x1.6c162fc9cbe02p-1, 0x1.5d1d758e45217p-2}, }; +#endif diff --git a/math/v_math.h b/math/v_math.h index f2bf24e..0861e98 100644 --- a/math/v_math.h +++ b/math/v_math.h @@ -8,6 +8,12 @@ #ifndef _V_MATH_H #define _V_MATH_H +#ifndef WANT_VMATH +/* Enable the build of vector math code. */ +# define WANT_VMATH 1 +#endif +#if WANT_VMATH + /* The goal of this header is to allow vector and scalar build of the same algorithm, the provided intrinsic wrappers are also vector length agnostic so they can @@ -602,3 +608,4 @@ v_call_f64 (f64_t (*f) (f64_t), v_f64_t x, v_f64_t y, v_u64_t p) #endif #endif +#endif -- cgit v1.2.3