[RFC] How to add vector math functions to Glibc
Joseph S. Myers
joseph@codesourcery.com
Tue Sep 30 20:15:00 GMT 2014
On Tue, 30 Sep 2014, Christoph Lauter wrote:
> Hi all,
>
> just 2cts from someone who wrote a couple of libm functions alreday in his
> life:
>
> Joseph S. Myers wrote on 30/09/2014 18:35:
>
> > > +# if defined _OPENMP && _OPENMP >= 201307
> > > +/* OpenMP case. */
> > > +# undef __DECL_SIMD_AVX2
> > > +# undef __DECL_SIMD_SSE4
> > > +# define __DECL_SIMD_AVX2 _Pragma("omp declare simd notinbranch")
> > > +# define __DECL_SIMD_SSE4 _Pragma("omp declare simd notinbranch")
> >
> > I think there should be a comment pointing to the ABI/API documentation
> > that says what function versions this pragma defines to be available and
> > guaranteeing that it will not be redefined to e.g. say that AVX512 is
> > available so that existing headers will work with future compilers (but
> > another pragma will be needed if in future AVX512 versions are added).
> >
>
> Yeah, the ABI/API is not quite self-documenting with functions declared as
> follows:
What I'm referring to here is somewhat different - it's the ABI/API that
defines the contact between the library and compiler implied by the pragma
(or, in the Cilk Plus case, by the attribute).
That ABI/API will effectively say "this pragma / attribute means that
versions of this function are available for the following vector ISAs"
(and then go on to say what the ABI is for each ISA). It should also say
explicitly that compilers must not interpret the pragma / attribute as
meaning that functions are available for any other vector ISAs and that
new pragmas / attributes will be defined for any new vector ISAs as
needed. That avoids future compilers misinterpreting glibc 2.21's headers
as meaning it provides e.g. AVX512 versions of functions.
This ABI/API should be generically about OpenMP / Cilk Plus on x86_64
processors, rather than specifically about GCC, to establish an
interpretation intended to be shared by any compiler that implements those
features, now or in the future.
(Of course then the patch does actually need to provide all the function
versions implied by the pragma / attribute.)
> > > + .align 64
> > > + .globl __gnu_svml_dcos_data
> > > +__gnu_svml_dcos_data:
> > > + .long 4294967295
> >
> > What are the semantics of the values in this table (please add a comment)?
> > How was this table generated?
> >
>
> Yeah, who codes floating-point values as (little-endian ?) memory notation in
> decimal? I would understand hexadecimal but decimal?
>
> As is, the code is unmaintainable.
And, generally, we want to be able to regenerate any such tables if there
are changes to the algorithms. This means at a minimum having comments
giving the semantics of the table (coefficients of whatever polynomial
approximation to a given function on given intervals, for example), but
preferably source code to generate the table.
--
Joseph S. Myers
joseph@codesourcery.com
More information about the Libc-alpha
mailing list