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: Mon, 27 Oct 2014 14:39:31 +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> <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> <Pine dot LNX dot 4 dot 64 dot 1410162141290 dot 32736 at digraph dot polyomino dot org dot uk> <CAMXFM3tf3EE-WenvnVohkFCkHR9Dy4QfaSiSHcw6Q-1o9QGW_Q at mail dot gmail dot com> <Pine dot LNX dot 4 dot 64 dot 1410211517340 dot 31277 at digraph dot polyomino dot org dot uk> <CAMXFM3t8xjQ7A6TF1SpY0GwzKpTQ9hZej4vKvSYHnnsxGkaONA at mail dot gmail dot com> <Pine dot LNX dot 4 dot 64 dot 1410232117130 dot 19073 at digraph dot polyomino dot org dot uk> <CAMXFM3tXKmObEpsgZ_Vb3q0knopt_W=DbvO38_0BMJ31EjbtTw at mail dot gmail dot com>
On Mon, 27 Oct 2014, Andrew Senkevich wrote:
> >> +# define __DECL_SIMD_cos __DECL_SIMD_AVX2
> >> +# define __DECL_SIMD_cosf __DECL_SIMD_SSE4
> >> +# elif defined _CILKPLUS && _CILKPLUS >= 0
> >> +/* CilkPlus case. TODO _CILKPLUS currently nowhere defined */
> >> +# define __DECL_SIMD_AVX2 __attribute__((__vector__(nomask)))
> >> +# define __DECL_SIMD_SSE4 __attribute__((__vector__(processor(core_i7_sse4_2),\
> >> + nomask)))
> >
> > And as previously noted, this needs to be fixed to be namespace-clean -
> > using __nomask__, __processor__, __core_i7_sse4_2__.
>
> It seems there are no such reserved-namespace word versions now...
Then fix the compiler to have such reserved-namespace versions and put
appropriate conditionals on a fixed compiler version in the header. It's
not OK to put random identifiers into an installed header like that.
> >> +#if defined TEST_MATHVEC
> >
> > No, you can't have such conditionals on a macro in the user's namespace in
> > an installed header.
>
> Then we have to build vector tests with -D__FAST_MATH__
> -DTEST_FAST_MATH -D_OPENMP=201307 to be sure we have needed
> definitions from math.h?
Yes, -D__FAST_MATH__ is used for some other libm tests.
> >> diff --git a/sysdeps/x86_64/configure.ac b/sysdeps/x86_64/configure.ac
> >> index c9f9a51..91c4cdf 100644
> >> --- a/sysdeps/x86_64/configure.ac
> >> +++ b/sysdeps/x86_64/configure.ac
> >> @@ -5,6 +5,24 @@ AC_CHECK_HEADER([cpuid.h], ,
> >> [AC_MSG_ERROR([gcc must provide the <cpuid.h> header])],
> >> [/* No default includes. */])
> >>
> >> +dnl Check if compiler target is x86_64.
> >
> > Not needed. preconfigure fragments in sysdeps directories need to check
> > the architecture, but configure ones don't (they'll only be run for the
> > relevant architecture, unless one fragment explicitly sources another).
>
> Clear, then it can be done in root configure like so:
> +if test x"$build_mathvec" = xnotset; then
> + if test x"$machine" = xx86_64/64; then
No. Such conditionals on particular systems do not go in the toplevel
configure script.
If you want something for x86_64 (both -m64 and -mx32), it can go in
sysdeps/x86_64/configure.ac, without any machine conditionals. And if
there's a good reason (please state the reason if so) something won't work
for x32, put it in sysdeps/x86_64/64/configure.ac, again with no machine
conditionals (and in that case, the implementation files would also go in
sysdeps/x86_64/64/ directories).
--
Joseph S. Myers
joseph@codesourcery.com