[PATCH] PowerPC - ilogb[f|l] optimization for POWER7
Ryan S. Arnold
ryan.arnold@gmail.com
Wed May 9 22:10:00 GMT 2012
On Tue, May 8, 2012 at 7:33 AM, Adhemerval Zanella
<azanella@linux.vnet.ibm.com> wrote:
> This patch provides optimized ilogb (60% on PPC32 and 20% PPC64),
> ilogbf (60% on PPC32 and 50% on PPC64), and ilogbl (3% on PPC32
> and 8% on PPC64). The optimization is done by avoiding float-point
> to integer transformation and by using VSX float-point bitwise
> instructions.
Please indicate why you chose to implement the changes the way you did
by removing e_ilogb.
> ---
>
> 2012-05-08 Adhemerval Zanella <azanella@linux.vnet.ibm.com>
>
> * sysdeps/powerpc/powerpc32/power7/fpu/w_ilogb.c: New file: optimized
> ilogb for POWER7.
> * sysdeps/powerpc/powerpc32/power7/fpu/w_ilogbf.c: New file: optimized
> ilogbf for POWER7.
> * sysdeps/powerpc/powerpc32/power7/fpu/w_ilogbl.c: New file: optimized
> ilogbl for POWER7.
> * sysdeps/powerpc/powerpc64/power7/fpu/w_ilogb.c: New file: wrapper
> for the optimized logb for PPC64.
> * sysdeps/powerpc/powerpc64/power7/fpu/w_ilogbf.c: New file: wrapper
> for the optimized logbf for PPC64.
> * sysdeps/powerpc/powerpc64/power7/fpu/w_ilogbl.c: New file: wrapper
> for the optimized logbl for PPC64.
Same comment as I had on the logb fixes. Please indicate that this
uses the powerpc32 version.
> * sysdeps/powerpc/powerpc32/power7/fpu/e_ilogb.c: New file: black file
> to avoid compilation of default implementation.
I assume you mean "blank" file.. but I prefer something like "dummy"
file because it's not exactly blank/empty.
> * sysdeps/powerpc/powerpc32/power7/fpu/e_ilogbf.c: Likewise.
> * sysdeps/powerpc/powerpc32/power7/fpu/e_ilogbl.c: Likewise.
> * sysdeps/powerpc/powerpc64/power7/fpu/e_ilogb.c: Likewise.
> * sysdeps/powerpc/powerpc64/power7/fpu/e_ilogbf.c: Likewise.
> * sysdeps/powerpc/powerpc64/power7/fpu/e_ilogbl.c: Likewise.
> * sysdeps/powerpc/fpu/math_private.h: Add Optimized double to word
> cast for POWER7.
> * math/libm-test.inc (ilogb_test): New ilogb tests.
>
> diff --git a/math/libm-test.inc b/math/libm-test.inc
> index 542131d..677e5e9 100644
> --- a/math/libm-test.inc
> +++ b/math/libm-test.inc
> @@ -4082,6 +4082,10 @@ ilogb_test (void)
> TEST_f_i (ilogb, M_El, 1);
> TEST_f_i (ilogb, 1024, 10);
> TEST_f_i (ilogb, -2000, 10);
> + TEST_f_i (ilogb, 1.701412e+38, 127);
> +#ifndef TEST_FLOAT
> + TEST_f_i (ilogb, 8.988466e+307, 1023);
> +#endif
>
> /* ilogb (0.0) == FP_ILOGB0 plus invalid exception */
> errno = 0;
> diff --git a/sysdeps/powerpc/fpu/math_private.h b/sysdeps/powerpc/fpu/math_private.h
> index a916be3..aa3053a 100644
> --- a/sysdeps/powerpc/fpu/math_private.h
> +++ b/sysdeps/powerpc/fpu/math_private.h
> @@ -25,6 +25,29 @@
> #include <dl-procinfo.h>
> #include_next <math_private.h>
>
> +#if defined(_ARCH_PWR7)
> +
> +/* Optimized double to word cast for POWER7: the 'ori 2,2,0'
> + instructions between the store double / load integer is
> + to force a new dispatch group. */
> +#undef DOUBLE_TO_WORDS
> +#define DOUBLE_TO_WORDS(d, i) \
> + do { \
> + double d__ = d; \
> + int32_t i__; \
> + ieee_double_shape_type iw_u; \
> + __asm ( \
> + "fctiwz %1,%1\n" \
> + "stfd %1,%2\n" \
> + "ori 2,2,0\n" \
> + "lwz %0,%3\n" \
> + : "=r" (i__) \
> + : "f" (d__), "m" (iw_u.value), "m" (iw_u.word)); \
> + i = i__; \
> + } while (0)
> +
> +#endif /* __ARCH_PWR7 */
> +
> # if __WORDSIZE == 64 || defined _ARCH_PWR4
> # define __CPU_HAS_FSQRT 1
> # else
> diff --git a/sysdeps/powerpc/powerpc32/power7/fpu/e_ilogb.c b/sysdeps/powerpc/powerpc32/power7/fpu/e_ilogb.c
> new file mode 100644
> index 0000000..34f1a9b
> --- /dev/null
> +++ b/sysdeps/powerpc/powerpc32/power7/fpu/e_ilogb.c
> @@ -0,0 +1 @@
> +/* ilogb implementation is at w_ilogb.c */
I think perhaps "in" is more correct in this case since the
implementation is contained within that particular file.
> diff --git a/sysdeps/powerpc/powerpc32/power7/fpu/e_ilogbf.c b/sysdeps/powerpc/powerpc32/power7/fpu/e_ilogbf.c
> new file mode 100644
> index 0000000..1bbe157
> --- /dev/null
> +++ b/sysdeps/powerpc/powerpc32/power7/fpu/e_ilogbf.c
> @@ -0,0 +1 @@
> +/* ilogbf implementation is at w_ilogbf.c */
> diff --git a/sysdeps/powerpc/powerpc32/power7/fpu/e_ilogbl.c b/sysdeps/powerpc/powerpc32/power7/fpu/e_ilogbl.c
> new file mode 100644
> index 0000000..7684390
> --- /dev/null
> +++ b/sysdeps/powerpc/powerpc32/power7/fpu/e_ilogbl.c
> @@ -0,0 +1 @@
> +/* ilogbl implementation is at w_ilogbl.c */
> diff --git a/sysdeps/powerpc/powerpc32/power7/fpu/w_ilogb.c b/sysdeps/powerpc/powerpc32/power7/fpu/w_ilogb.c
> new file mode 100644
> index 0000000..525f76b
> --- /dev/null
> +++ b/sysdeps/powerpc/powerpc32/power7/fpu/w_ilogb.c
> @@ -0,0 +1,83 @@
> +/* ilogb(). PowerPC64/POWER7 version.
> + Copyright (C) 2012 Free Software Foundation, Inc.
> + Contributed by Adhemerval Zanella Netto <azanella@br.ibm.com>.
Remove the Contributed by line, here and elsewhere.
> + 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/>. */
> +
> +#include <fenv.h>
> +#include <errno.h>
> +#include <math.h>
> +#include <math_private.h>
> +
> +
Nit, remove extra empty line ^^^ in this file an others.
I have no further comments.
I technically it's OK.
Ryan
More information about the Libc-alpha
mailing list