From 3560d66f2efb0164821681e5006280b2f6dadd07 Mon Sep 17 00:00:00 2001 From: Joe Ramsay Date: Tue, 15 Nov 2022 12:31:04 +0000 Subject: math/test: Allow user to set control element of input vector argf and argd have been designed such that non-special input is tested, optionally followed by a vector with one special lane. To be able to test that vector functions have correct behaviour w.r.t. fenv exceptions, we need to be able to choose a different value for the last lane, as using 1 leads to false negatives when testing a function for which 1 is a special value. We add an option, -c, for the user to provide a different control value. --- math/test/ulp.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'math') diff --git a/math/test/ulp.c b/math/test/ulp.c index 24185a2..e011ae3 100644 --- a/math/test/ulp.c +++ b/math/test/ulp.c @@ -223,8 +223,9 @@ static int secondcall; #if __aarch64__ && WANT_VMATH typedef __f32x4_t v_float; typedef __f64x2_t v_double; -static const float fv[2] = {1.0f, -INFINITY}; -static const double dv[2] = {1.0, -INFINITY}; +/* First element of fv and dv may be changed by -c argument. */ +static float fv[2] = {1.0f, -INFINITY}; +static 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]}; } #if WANT_SVE_MATH @@ -633,6 +634,9 @@ usage (void) puts ("-q: quiet."); puts ("-m: use mpfr even if faster method is available."); puts ("-f: disable fenv testing (rounding modes and exceptions)."); + puts ("-c: neutral 'control value' to test behaviour when one lane can affect another. \n" + " This should be different from tested input in other lanes, and non-special \n" + " (i.e. should not trigger fenv exceptions). Default is 1."); puts ("Supported func:"); for (const struct fun *f = fun; f->name; f++) printf ("\t%s\n", f->name); @@ -800,6 +804,12 @@ main (int argc, char *argv[]) conf.rc = argv[0][0]; } break; + case 'c': + argc--; + argv++; + fv[0] = strtof(argv[0], 0); + dv[0] = strtod(argv[0], 0); + break; default: usage (); } -- cgit v1.2.3