[RFC] How to add vector math functions to Glibc
Joseph S. Myers
joseph@codesourcery.com
Thu Oct 16 21:51:00 GMT 2014
On Thu, 16 Oct 2014, Andrew Senkevich wrote:
> >> @@ -6258,7 +6274,11 @@ static const struct test_f_f_data cos_test_data[] =
> >> static void
> >> cos_test (void)
> >> {
> >> +#ifndef TEST_MATHVEC
> >> ALL_RM_TEST (cos, 0, cos_test_data, RUN_TEST_LOOP_f_f, END);
> >> +#else
> >> + TN_RM_TEST (vector_cos, 0, cos_test_data, RUN_TEST_LOOP_f_f, END);
> >> +#endif
> >> }
> >
> > And I don't think we want conditionals like this for every function -
> > indeed, the tests shouldn't need to know which functions have vector
> > versions at all.
>
> Do you mean to use the same *_test function for testing vector
> (through wrapper)?
Yes. I don't have a full design, but the principle is to change how the
macros for running tests expand (or what functions they call do)
conditional on what is being tested, so that none of the conditionals are
at the level of individual functions if it can be avoided. And I don't
think you should need to change calls to START, just the expansion.
> Because of vector tests grouped by ISA we have different test driver
> names containing vector length (test-double-vlen4.c for AVX2).
> Scalar wrappers (called from test driver) will be in separate files
> (test-double-vlen4-wrapper.c) and will be built with
> architecture-specific options specified in sysdeps Makefile.
> For runtime check we need to insert condition before wrapper start so
> with help of new macros added in *_test function that condition could
> be defined in test driver.
I'd think that the check for AVX2 etc. availability could run once in
main, rather than in the tests of individual functions.
> @@ -6247,7 +6248,7 @@ copysign_test (void)
>
>
> static const struct test_f_f_data cos_test_data[] =
> - {
> + {
This looks like a bogus diff hunk.
> + /* Vector trigonometric functions: */
> +#ifdef TEST_MATHVEC
> +
> + cos_test ();
> +
> +#else
There shouldn't be such conditionals. It should be arranged that if
there isn't a relevant vector version of a particular function, running
vector tests for that function does nothing - so there are no conditionals
on which *_test functions to run, and none inside those functions, just
conditionals affecting what the test macros do (by means of conditionals
inside them such as if (HAVE_VECTOR_cos_double_vlen4), for example,
resulting from appropriate concatenations).
> diff --git a/sysdeps/x86_64/fpu/libm-test-ulps
> b/sysdeps/x86_64/fpu/libm-test-ulps
> index 36e1b76..0e11cd5 100644
> --- a/sysdeps/x86_64/fpu/libm-test-ulps
> +++ b/sysdeps/x86_64/fpu/libm-test-ulps
> @@ -905,6 +905,12 @@ idouble: 1
> ildouble: 2
> ldouble: 2
>
> +
> +Function: "vlen4_cos":
> +double: 1
> +
> Function: "cosh":
> double: 1
> float: 1
This looks odd. There shouldn't be the double blank line, and entries
should be sorted alphabetically - this file should be updated by "make
regen-ulps", and you need to ensure that regen-ulps does include the ulps
for the tests of the vector functions.
--
Joseph S. Myers
joseph@codesourcery.com
More information about the Libc-alpha
mailing list