Message ID | 1526532912-1716-1-git-send-email-raji@linux.vnet.ibm.com |
---|---|
State | New |
Headers | show |
Series | powerpc: Add multiarch sqrtf128 for ppc64le | expand |
On Thu, 17 May 2018, Rajalakshmi Srinivasaraghavan wrote: >This patch creates ifunc for sqrtf128() to make use of new xssqrtqp >instruction for POWER9 when --enable-multi-arch and --with-cpu=power8 >options are used on power9 system. This is achieved by explicitly >adding -mcpu=power9 flag for sqrtf128-power9. > >2018-05-17 Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com> > > * sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile: New file to > add w_sqrtf128-power9 and w_sqrtf128-ppc64le to libm-sysdep_routines. > * sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_sqrtf128-power9.c: > New file. > * sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_sqrtf128-ppc64le.c: > Likewise. > * sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_sqrtf128.c: Likewise. This part looks good to me. > * sysdeps/powerpc/powerpc64/le/power9/fpu/e_sqrtf128.c: Remove file > as __ieee754_sqrtf128() for power9 is present already in > sysdeps/powerpc/fpu/math_private.h. This doesn't. The function provided by e_sqrtf128.c (__sqrtf128_finite) is export by GLIBC and accessible by users when they are building their code with -ffast-math. When building glibc with --with-cpu=power8, removing this file would be OK. However, when building glibc with --with-cpu=power9, __sqrtf128_finite will use software emulation when it could use xssqrtqp. Since math_private.h is not installed, it will not work for glibc users. You patch is OK without this removal. >+++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_sqrtf128-power9.c > (...) >+#include <math-type-macros-float128.h> > (...) >+#undef __USE_WRAPPER_TEMPLATE >+#define __USE_WRAPPER_TEMPLATE 1 Do you actually need this? What behaviour are you trying to override? The float128 implementation always uses the wrapper templates. >+++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_sqrtf128-ppc64le.c > (...) >+#include <math-type-macros-float128.h> > (...) >+#undef __USE_WRAPPER_TEMPLATE >+#define __USE_WRAPPER_TEMPLATE 1 Likewise. >+++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_sqrtf128.c > (...) >+libc_ifunc (__sqrtf128, >+ (hwcap2 & PPC_FEATURE2_ARCH_3_00) >+ ? __sqrtf128_power9 >+ : __sqrtf128_ppc64le); >+declare_mgen_alias (__sqrt, sqrt) OK.
On 05/29/2018 09:07 PM, Gabriel F. T. Gomes wrote: > On Thu, 17 May 2018, Rajalakshmi Srinivasaraghavan wrote: > >> This patch creates ifunc for sqrtf128() to make use of new xssqrtqp >> instruction for POWER9 when --enable-multi-arch and --with-cpu=power8 >> options are used on power9 system. This is achieved by explicitly >> adding -mcpu=power9 flag for sqrtf128-power9. >> >> 2018-05-17 Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com> >> >> * sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile: New file to >> add w_sqrtf128-power9 and w_sqrtf128-ppc64le to libm-sysdep_routines. >> * sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_sqrtf128-power9.c: >> New file. >> * sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_sqrtf128-ppc64le.c: >> Likewise. >> * sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_sqrtf128.c: Likewise. > > This part looks good to me. Thanks for the review. > >> * sysdeps/powerpc/powerpc64/le/power9/fpu/e_sqrtf128.c: Remove file >> as __ieee754_sqrtf128() for power9 is present already in >> sysdeps/powerpc/fpu/math_private.h. > > This doesn't. > > The function provided by e_sqrtf128.c (__sqrtf128_finite) is export by > GLIBC and accessible by users when they are building their code with > -ffast-math. When building glibc with --with-cpu=power8, removing this > file would be OK. However, when building glibc with --with-cpu=power9, > __sqrtf128_finite will use software emulation when it could use xssqrtqp. > Since math_private.h is not installed, it will not work for glibc users. > > You patch is OK without this removal. Good catch. Ack. > >> +++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_sqrtf128-power9.c >> (...) >> +#include <math-type-macros-float128.h> >> (...) >> +#undef __USE_WRAPPER_TEMPLATE >> +#define __USE_WRAPPER_TEMPLATE 1 > > Do you actually need this? What behaviour are you trying to override? > The float128 implementation always uses the wrapper templates. Yes. This is not needed. > >> +++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_sqrtf128-ppc64le.c >> (...) >> +#include <math-type-macros-float128.h> >> (...) >> +#undef __USE_WRAPPER_TEMPLATE >> +#define __USE_WRAPPER_TEMPLATE 1 > > Likewise. > >> +++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_sqrtf128.c >> (...) >> +libc_ifunc (__sqrtf128, >> + (hwcap2 & PPC_FEATURE2_ARCH_3_00) >> + ? __sqrtf128_power9 >> + : __sqrtf128_ppc64le); >> +declare_mgen_alias (__sqrt, sqrt) > > OK. Pushed as 2c93fce76a8e672abfdf7771c97be9ea49b7222b. > >
diff --git a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile new file mode 100644 index 0000000000..a32f3d8b81 --- /dev/null +++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile @@ -0,0 +1,6 @@ +ifeq ($(subdir),math) +libm-sysdep_routines += w_sqrtf128-power9 w_sqrtf128-ppc64le + +CFLAGS-w_sqrtf128-ppc64le.c += -mfloat128 +CFLAGS-w_sqrtf128-power9.c += -mfloat128 -mcpu=power9 +endif diff --git a/sysdeps/powerpc/powerpc64/le/power9/fpu/e_sqrtf128.c b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_sqrtf128-power9.c similarity index 81% rename from sysdeps/powerpc/powerpc64/le/power9/fpu/e_sqrtf128.c rename to sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_sqrtf128-power9.c index 76ab451dbb..0629060754 100644 --- a/sysdeps/powerpc/powerpc64/le/power9/fpu/e_sqrtf128.c +++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_sqrtf128-power9.c @@ -1,6 +1,5 @@ /* POWER9 sqrt for _Float128 - Return sqrt(a) - Copyright (C) 2017-2018 Free Software Foundation, Inc. + Copyright (C) 2018 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 @@ -26,11 +25,13 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ -__float128 -__ieee754_sqrtf128 (__float128 a) -{ - __float128 z; - asm ("xssqrtqp %0,%1" : "=v" (z) : "v" (a)); - return z; -} -strong_alias (__ieee754_sqrtf128, __sqrtf128_finite) +#include <math-type-macros-float128.h> + +#define __sqrtf128 __sqrtf128_power9 + +#undef __USE_WRAPPER_TEMPLATE +#define __USE_WRAPPER_TEMPLATE 1 +#undef declare_mgen_alias +#define declare_mgen_alias(a, b) + +#include <w_sqrt_template.c> diff --git a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_sqrtf128-ppc64le.c b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_sqrtf128-ppc64le.c new file mode 100644 index 0000000000..313ef8ba9a --- /dev/null +++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_sqrtf128-ppc64le.c @@ -0,0 +1,37 @@ +/* PPC64LE sqrt for _Float128 + Copyright (C) 2018 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. + + In addition to the permissions in the GNU Lesser General Public + License, the Free Software Foundation gives you unlimited + permission to link the compiled version of this file into + combinations with other programs, and to distribute those + combinations without any restriction coming from the use of this + file. (The Lesser General Public License restrictions do apply in + other respects; for example, they cover modification of the file, + and distribution when not linked into a combine executable.) + + 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/>. */ + +#include <math-type-macros-float128.h> + +#define __sqrtf128 __sqrtf128_ppc64le + +#undef __USE_WRAPPER_TEMPLATE +#define __USE_WRAPPER_TEMPLATE 1 +#undef declare_mgen_alias +#define declare_mgen_alias(a, b) + +#include <w_sqrt_template.c> diff --git a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_sqrtf128.c b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_sqrtf128.c new file mode 100644 index 0000000000..a44bf4f5cc --- /dev/null +++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/w_sqrtf128.c @@ -0,0 +1,31 @@ +/* Multiple versions of __sqrtf128. + Copyright (C) 2018 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/>. */ + +#define NO_MATH_REDIRECT +#include <math.h> +#include "init-arch.h" +#include <math-type-macros-float128.h> + +extern __typeof (__sqrtf128) __sqrtf128_ppc64le attribute_hidden; +extern __typeof (__sqrtf128) __sqrtf128_power9 attribute_hidden; + +libc_ifunc (__sqrtf128, + (hwcap2 & PPC_FEATURE2_ARCH_3_00) + ? __sqrtf128_power9 + : __sqrtf128_ppc64le); +declare_mgen_alias (__sqrt, sqrt)