Message ID | ea70c1dee76d6c2253bac2940e0c09ab6c90102a.camel@marvell.com |
---|---|

State | New |

Headers | show |

Series | RFC: Patch to avoid using _finite calls in some cases (including in libmvec names) | expand |

On Wed, 13 Mar 2019, Steve Ellcey wrote: > Joseph suggested putting a '__vector_name__' attribute on functions that > have libmvec vector version, then we could use that name (expf) instead > of the assembler name (__expf_finite) to form the libmvec name. The > objection here is that both C and Fortran would have to handle this new > attribute and anyone building glibc with a non GCC compiler would also > have to add support for the new attribute. Fortran would not have to handle that attribute. Fortran never gets _finite names in the first place because it can't parse the C header which is how C code gets the _finite names. In the powerpc64le long double context, Fortran (and other languages working with C libraries such as D) not parsing C headers requires some special compiler support to handle remapping the names of relevant library functions (or else glibc support for generating lists of remappings for use from other languages, etc.). But in the libmvec context, those languages not parsing C headers means that _finite isn't an issue at all for libmvec use for such languages. > On Aarch64, expf and expf_finite (and the other exp routines) are > aliases for each other and the vector versions would also be aliases, That's not the case for expl, which by itself makes this patch suboptimal (losing use of __expl_finite while it still does something more efficient than expl). > so I would like to change math-finite.h to allow platforms to decide > whether or not to use the _finite names in calls. This would affect > both the scalar and vector versions and all types (float, double, long > double). We also know that significant changes to handling of _finite functions will be needed to avoid double redirections (which don't actually work) for non-default long double formats. See bug 23292 (and my review saying this indicates merging bits/math-finite.h into bits/mathcalls.h). It's not clear how a version using __MATHCALL_FINITE or similar to declare functions in bits/mathcalls.h could readily handle such per-function, per-architecture, per-type conditionals. I still think independent asm names for scalar and vector functions is the right approach here.

diff --git a/bits/math-finite-funcs.h b/bits/math-finite-funcs.h index e69de29..1ac64ac 100644 --- a/bits/math-finite-funcs.h +++ b/bits/math-finite-funcs.h @@ -0,0 +1,31 @@ +/* List of functions where the *_finite versions match the normal versions. + Copyright (C) 2011-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#ifndef _MATH_H +# error "Never use <bits/math-finite-funcs.h> directly; include <math.h> instead." +#endif + +/* By default we set the names of all the functions in math-finite.h to have + the _finite suffix so that when __FINITE_MATH_ONLY__ is set we call the + _finite version of the routines. On platforms where the normal version and + the _finite version are the same we allow the name to not be changed so that + the call is to the original name. This is done by setting + '__GLIBC_SKIP_MATH_FINITE_<NAME>'. + + This has the side-affect of changing the name of the vectorized version of + the function if such a function exists. */ diff --git a/bits/math-finite.h b/bits/math-finite.h index 6141c12..b9a652a 100644 --- a/bits/math-finite.h +++ b/bits/math-finite.h @@ -65,7 +65,9 @@ __MATH_REDIRCALL (atanh, , (_Mdouble_)); __MATH_REDIRCALL (cosh, , (_Mdouble_)); /* exp. */ +#ifndef __GLIBC_SKIP_MATH_FINITE_EXP __MATH_REDIRCALL (exp, , (_Mdouble_)); +#endif #if __GLIBC_USE (IEC_60559_FUNCS_EXT) /* exp10. */ diff --git a/math/Makefile b/math/Makefile index cb4eaec..4306289 100644 --- a/math/Makefile +++ b/math/Makefile @@ -25,8 +25,8 @@ include ../Makeconfig headers := math.h bits/mathcalls.h bits/mathinline.h \ fpu_control.h complex.h bits/cmathcalls.h fenv.h \ bits/fenv.h bits/fenvinline.h bits/mathdef.h tgmath.h \ - bits/math-finite.h bits/math-vector.h \ - finclude/math-vector-fortran.h \ + bits/math-finite.h bits/math-finite-funcs.h \ + bits/math-vector.h finclude/math-vector-fortran.h \ bits/libm-simd-decl-stubs.h bits/iscanonical.h \ bits/flt-eval-method.h bits/fp-fast.h bits/fp-logb.h \ bits/long-double.h bits/mathcalls-helper-functions.h \ diff --git a/math/math.h b/math/math.h index ffbc24a..8ac35e6 100644 --- a/math/math.h +++ b/math/math.h @@ -1240,6 +1240,10 @@ iszero (__T __val) # include <bits/mathinline.h> #endif +/* Get machine-depenedent list of functions that do not need + finite versions. */ +#include <bits/math-finite-funcs.h> + /* Define special entry points to use when the compiler got told to only expect finite results. */ #if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0 diff --git a/sysdeps/aarch64/fpu/bits/math-finite-funcs.h b/sysdeps/aarch64/fpu/bits/math-finite-funcs.h index e69de29..e6e4154 100644 --- a/sysdeps/aarch64/fpu/bits/math-finite-funcs.h +++ b/sysdeps/aarch64/fpu/bits/math-finite-funcs.h @@ -0,0 +1,23 @@ +/* Platform specific list of functions that do not need *_finite versions. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#ifndef _MATH_H +# error "Never use <bits/math-finite-funcs.h> directly; include <math.h> instead." +#endif + +#define __GLIBC_SKIP_MATH_FINITE_EXP 1