[RFC] How to add vector math functions to Glibc
Joseph S. Myers
joseph@codesourcery.com
Mon Oct 27 14:39:00 GMT 2014
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
More information about the Libc-alpha
mailing list