diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2017-09-19 18:58:13 +0000 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2017-09-19 16:12:23 -0300 |
commit | ced72fd9d386675cf1ed9e5093a4a73b5857d921 (patch) | |
tree | cc323df37e0b48fb56280300b9d4f427b07fa3ec | |
parent | 3988adaf704a30af6a9b1a889c1e5b6724301653 (diff) | |
download | glibc-azanella/memopt-power8.tar.gz |
POWER8 memcpy tunablesazanella/memopt-power8
-rw-r--r-- | sysdeps/powerpc/cpu-features.c | 39 | ||||
-rw-r--r-- | sysdeps/powerpc/cpu-features.h | 28 | ||||
-rw-r--r-- | sysdeps/powerpc/dl-procinfo.c | 16 | ||||
-rw-r--r-- | sysdeps/powerpc/dl-tunables.list | 28 | ||||
-rw-r--r-- | sysdeps/powerpc/ldsodefs.h | 1 | ||||
-rw-r--r-- | sysdeps/powerpc/powerpc32/power4/multiarch/init-arch.h | 2 | ||||
-rw-r--r-- | sysdeps/powerpc/powerpc64/dl-irel.h | 1 | ||||
-rw-r--r-- | sysdeps/powerpc/powerpc64/dl-machine.h | 2 | ||||
-rw-r--r-- | sysdeps/powerpc/powerpc64/multiarch/memcpy.c | 23 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/powerpc/gettimeofday.c | 1 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/powerpc/time.c | 1 |
11 files changed, 129 insertions, 13 deletions
diff --git a/sysdeps/powerpc/cpu-features.c b/sysdeps/powerpc/cpu-features.c new file mode 100644 index 0000000000..fd9debceab --- /dev/null +++ b/sysdeps/powerpc/cpu-features.c @@ -0,0 +1,39 @@ +/* Initialize cpu feature data. PowerPC version. + this file is part of the gnu c library. + copyright (c) 2017 free software foundation, inc. + + 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 <stdint.h> +#include <cpu-features.h> + +#if HAVE_TUNABLES +# include <elf/dl-tunables.h> +#endif + +static inline void +init_cpu_features (struct cpu_features *cpu_features) +{ + /* Default is to use aligned memory access on optimized function unless + tunables is enable, since for this case user can explicit disable + unaligned optimizations. */ +#if HAVE_TUNABLES + int32_t aligned_memfunc = TUNABLE_GET (glibc, tune, aligned_memopt, int32_t, + NULL); + cpu_features->use_aligned_memopt = (aligned_memfunc > 0); +#else + cpu_features->use_aligned_memopt = true; +#endif +} diff --git a/sysdeps/powerpc/cpu-features.h b/sysdeps/powerpc/cpu-features.h new file mode 100644 index 0000000000..74409c63fe --- /dev/null +++ b/sysdeps/powerpc/cpu-features.h @@ -0,0 +1,28 @@ +/* Initialize cpu feature data. PowerPC version. + Copyright (C) 2017 Free Software Foundation, Inc. + + 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 __CPU_FEATURES_POWERPC_H +# define __CPU_FEATURES_POWERPC_H + +#include <stdbool.h> + +struct cpu_features +{ + bool use_aligned_memopt; +}; + +#endif /* __CPU_FEATURES_H */ diff --git a/sysdeps/powerpc/dl-procinfo.c b/sysdeps/powerpc/dl-procinfo.c index 4dac16d39e..0b055a5e26 100644 --- a/sysdeps/powerpc/dl-procinfo.c +++ b/sysdeps/powerpc/dl-procinfo.c @@ -42,6 +42,22 @@ # define PROCINFO_CLASS #endif +#if !IS_IN (ldconfig) +# if !defined PROCINFO_DECL && defined SHARED + ._dl_powerpc_cpu_features +# else +PROCINFO_CLASS struct cpu_features _dl_powerpc_cpu_features +# endif +# ifndef PROCINFO_DECL += { } +# endif +# if !defined SHARED || defined PROCINFO_DECL +; +# else +, +# endif +#endif + #if !defined PROCINFO_DECL && defined SHARED ._dl_powerpc_cap_flags #else diff --git a/sysdeps/powerpc/dl-tunables.list b/sysdeps/powerpc/dl-tunables.list new file mode 100644 index 0000000000..9212e4e5c9 --- /dev/null +++ b/sysdeps/powerpc/dl-tunables.list @@ -0,0 +1,28 @@ +# powerpc specific tunables. +# Copyright (C) 2017 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/>. + +glibc { + tune { + aligned_memopt { + type: INT_32 + minval: 0 + maxval: 1 + default: 0 + } + } +} diff --git a/sysdeps/powerpc/ldsodefs.h b/sysdeps/powerpc/ldsodefs.h index 466de797fc..6f8b3a2054 100644 --- a/sysdeps/powerpc/ldsodefs.h +++ b/sysdeps/powerpc/ldsodefs.h @@ -20,6 +20,7 @@ #define _POWERPC_LDSODEFS_H 1 #include <elf.h> +#include <cpu-features.h> struct La_ppc32_regs; struct La_ppc32_retval; diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/init-arch.h b/sysdeps/powerpc/powerpc32/power4/multiarch/init-arch.h index f2e6a4b705..e7e45b95c0 100644 --- a/sysdeps/powerpc/powerpc32/power4/multiarch/init-arch.h +++ b/sysdeps/powerpc/powerpc32/power4/multiarch/init-arch.h @@ -37,6 +37,8 @@ #define INIT_ARCH() \ unsigned long int hwcap = __GLRO(dl_hwcap); \ unsigned long int __attribute__((unused)) hwcap2 = __GLRO(dl_hwcap2); \ + bool __attribute__((unused)) use_aligned_memopt = \ + GLRO(dl_powerpc_cpu_features).use_aligned_memopt; \ if (hwcap & PPC_FEATURE_ARCH_2_06) \ hwcap |= PPC_FEATURE_ARCH_2_05 | \ PPC_FEATURE_POWER5_PLUS | \ diff --git a/sysdeps/powerpc/powerpc64/dl-irel.h b/sysdeps/powerpc/powerpc64/dl-irel.h index d8f5988bc9..fb9a545ee1 100644 --- a/sysdeps/powerpc/powerpc64/dl-irel.h +++ b/sysdeps/powerpc/powerpc64/dl-irel.h @@ -23,7 +23,6 @@ #include <stdio.h> #include <unistd.h> #include <ldsodefs.h> -#include <dl-machine.h> #define ELF_MACHINE_IRELA 1 diff --git a/sysdeps/powerpc/powerpc64/dl-machine.h b/sysdeps/powerpc/powerpc64/dl-machine.h index aeb91b8f69..bb99ec5122 100644 --- a/sysdeps/powerpc/powerpc64/dl-machine.h +++ b/sysdeps/powerpc/powerpc64/dl-machine.h @@ -27,6 +27,7 @@ #include <dl-tls.h> #include <sysdep.h> #include <hwcapinfo.h> +#include <cpu-features.c> /* Translate a processor specific dynamic tag to the index in l_info array. */ @@ -307,6 +308,7 @@ static inline void __attribute__ ((unused)) dl_platform_init (void) { __tcb_parse_hwcap_and_convert_at_platform (); + init_cpu_features (&GLRO(dl_powerpc_cpu_features)); } #endif diff --git a/sysdeps/powerpc/powerpc64/multiarch/memcpy.c b/sysdeps/powerpc/powerpc64/multiarch/memcpy.c index 9f4286c4fe..b30a51eb68 100644 --- a/sysdeps/powerpc/powerpc64/multiarch/memcpy.c +++ b/sysdeps/powerpc/powerpc64/multiarch/memcpy.c @@ -35,18 +35,21 @@ extern __typeof (__redirect_memcpy) __memcpy_cell attribute_hidden; extern __typeof (__redirect_memcpy) __memcpy_power6 attribute_hidden; extern __typeof (__redirect_memcpy) __memcpy_a2 attribute_hidden; extern __typeof (__redirect_memcpy) __memcpy_power7 attribute_hidden; +extern __typeof (__redirect_memcpy) __memcpy_power8 attribute_hidden; libc_ifunc (__libc_memcpy, - (hwcap & PPC_FEATURE_HAS_VSX) - ? __memcpy_power7 : - (hwcap & PPC_FEATURE_ARCH_2_06) - ? __memcpy_a2 : - (hwcap & PPC_FEATURE_ARCH_2_05) - ? __memcpy_power6 : - (hwcap & PPC_FEATURE_CELL_BE) - ? __memcpy_cell : - (hwcap & PPC_FEATURE_POWER4) - ? __memcpy_power4 + ((hwcap2 & PPC_FEATURE2_ARCH_2_07) && !use_aligned_memopt) + ? __memcpy_power8 : + (hwcap & PPC_FEATURE_HAS_VSX) + ? __memcpy_power7 : + (hwcap & PPC_FEATURE_ARCH_2_06) + ? __memcpy_a2 : + (hwcap & PPC_FEATURE_ARCH_2_05) + ? __memcpy_power6 : + (hwcap & PPC_FEATURE_CELL_BE) + ? __memcpy_cell : + (hwcap & PPC_FEATURE_POWER4) + ? __memcpy_power4 : __memcpy_ppc); #undef memcpy diff --git a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c index 6f09fa20d3..6ece7f45d3 100644 --- a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c +++ b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c @@ -27,7 +27,6 @@ # include <dl-vdso.h> # include <libc-vdso.h> -# include <dl-machine.h> # ifndef __powerpc64__ # undef __gettimeofday diff --git a/sysdeps/unix/sysv/linux/powerpc/time.c b/sysdeps/unix/sysv/linux/powerpc/time.c index 8fc901ee22..5fd5396434 100644 --- a/sysdeps/unix/sysv/linux/powerpc/time.c +++ b/sysdeps/unix/sysv/linux/powerpc/time.c @@ -27,7 +27,6 @@ # include <sysdep.h> # include <dl-vdso.h> # include <libc-vdso.h> -# include <dl-machine.h> # ifndef __powerpc64__ # undef time |