This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [RFC] How to add vector math functions to Glibc
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Andrew Senkevich <andrew dot n dot senkevich at gmail dot com>
- Cc: libc-alpha <libc-alpha at sourceware dot org>
- Date: Thu, 16 Oct 2014 21:51:23 +0000
- Subject: Re: [RFC] How to add vector math functions to Glibc
- Authentication-results: sourceware.org; auth=none
- References: <CAMXFM3tjquzniXP1weqxSVFJyhXqsf2PHuyrrrmqp7K0ZzORqA at mail dot gmail dot com> <54246CB5 dot 7020908 at redhat dot com> <CAMe9rOoLmJ2jHWmERoB0M83WNKovJOgh0--Kquw9O86A1tPU0g at mail dot gmail dot com> <5424733D dot 6010305 at redhat dot com> <CAMe9rOpacze055qyBFzz3M-b-GNtXCqZzMmkScBL9a94zVj28g at mail dot gmail dot com> <54247FAB dot 6050002 at redhat dot com> <CAMXFM3v8narOLMHC5U=fvyTFWV6s4ZACN-UrAC4fAcUs9SOFfA at mail dot gmail dot com> <54257507 dot 9070508 at redhat dot com> <CAMXFM3vOLspQtHxgJfD_Emht480w2RMbiwnEH6A_LhoS-JZFag at mail dot gmail dot com> <Pine dot LNX dot 4 dot 64 dot 1409301620020 dot 15186 at digraph dot polyomino dot org dot uk> <542AF92E dot 8090708 at lip6 dot fr> <Pine dot LNX dot 4 dot 64 dot 1409302003410 dot 12188 at digraph dot polyomino dot org dot uk> <CAMXFM3tuM_p6Acp4hzoQ2xzR=4BZqtw8NbezqY6h8V4Xx=5hUA at mail dot gmail dot com> <Pine dot LNX dot 4 dot 64 dot 1410021411420 dot 24886 at digraph dot polyomino dot org dot uk> <CAMXFM3uPiuJvSpgmt+8d0B1qh3QSA=TVx0ZExfojDVHzrscL8A at mail dot gmail dot com> <Pine dot LNX dot 4 dot 64 dot 1410091724031 dot 23641 at digraph dot polyomino dot org dot uk> <CAMXFM3uGOKqEAvGYew+9K7bmhObVmnP2u4kUOSh8_Cpwyk8s5g at mail dot gmail dot com>
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