This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
GNU C Library master sources branch azanella/memopt-power8 created. glibc-2.26-363-gced72fd
- From: azanella at sourceware dot org
- To: glibc-cvs at sourceware dot org
- Date: 19 Sep 2017 19:13:23 -0000
- Subject: GNU C Library master sources branch azanella/memopt-power8 created. glibc-2.26-363-gced72fd
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, azanella/memopt-power8 has been created
at ced72fd9d386675cf1ed9e5093a4a73b5857d921 (commit)
- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=ced72fd9d386675cf1ed9e5093a4a73b5857d921
commit ced72fd9d386675cf1ed9e5093a4a73b5857d921
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Tue Sep 19 18:58:13 2017 +0000
POWER8 memcpy tunables
diff --git a/sysdeps/powerpc/cpu-features.c b/sysdeps/powerpc/cpu-features.c
new file mode 100644
index 0000000..fd9debc
--- /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 0000000..74409c6
--- /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 4dac16d..0b055a5 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 0000000..9212e4e
--- /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 466de79..6f8b3a2 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 f2e6a4b..e7e45b9 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 d8f5988..fb9a545 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 aeb91b8..bb99ec5 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 9f4286c..b30a51e 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 6f09fa2..6ece7f4 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 8fc901e..5fd5396 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
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=3988adaf704a30af6a9b1a889c1e5b6724301653
commit 3988adaf704a30af6a9b1a889c1e5b6724301653
Author: Adhemerval Zanella <azanella@linux.vnet.ibm.com>
Date: Fri Jan 30 14:43:57 2015 -0500
powerpc: POWER8 memcpy optimization
diff --git a/sysdeps/powerpc/powerpc64/multiarch/Makefile b/sysdeps/powerpc/powerpc64/multiarch/Makefile
index f6491a2..39af19e 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/Makefile
+++ b/sysdeps/powerpc/powerpc64/multiarch/Makefile
@@ -1,6 +1,6 @@
ifeq ($(subdir),string)
-sysdep_routines += memcpy-power7 memcpy-a2 memcpy-power6 memcpy-cell \
- memcpy-power4 memcpy-ppc64 \
+sysdep_routines += memcpy-power8 memcpy-power7 memcpy-a2 memcpy-power6 \
+ memcpy-cell memcpy-power4 memcpy-ppc64 \
memcmp-power8 memcmp-power7 memcmp-power4 memcmp-ppc64 \
memset-power7 memset-power6 memset-power4 \
memset-ppc64 memset-power8 \
diff --git a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
index a1d3ca0..630f52a 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
@@ -51,6 +51,8 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
#ifdef SHARED
/* Support sysdeps/powerpc/powerpc64/multiarch/memcpy.c. */
IFUNC_IMPL (i, name, memcpy,
+ IFUNC_IMPL_ADD (array, i, memcpy, hwcap2 & PPC_FEATURE2_ARCH_2_07,
+ __memcpy_power8)
IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_HAS_VSX,
__memcpy_power7)
IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_ARCH_2_06,
diff --git a/sysdeps/powerpc/powerpc64/multiarch/memcpy-power8.S b/sysdeps/powerpc/powerpc64/multiarch/memcpy-power8.S
new file mode 100644
index 0000000..74b3330
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/multiarch/memcpy-power8.S
@@ -0,0 +1,26 @@
+/* Optimized memcpy implementation for PowerPC/POWER8.
+ Copyright (C) 2015 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/>. */
+
+#include <sysdep.h>
+
+#define MEMCPY __memcpy_power8
+
+#undef libc_hidden_builtin_def
+#define libc_hidden_builtin_def(name)
+
+#include <sysdeps/powerpc/powerpc64/power8/memcpy.S>
diff --git a/sysdeps/powerpc/powerpc64/power8/memcpy.S b/sysdeps/powerpc/powerpc64/power8/memcpy.S
new file mode 100644
index 0000000..8a6ae1b
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/power8/memcpy.S
@@ -0,0 +1,181 @@
+/* Optimized memcpy implementation for PowerPC64/POWER8.
+ 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/>. */
+
+#include <sysdep.h>
+
+
+/* __ptr_t [r3] memcpy (__ptr_t dst [r3], __ptr_t src [r4], size_t len [r5]);
+ Returns 'dst'. */
+
+#ifndef MEMCPY
+# define MEMCPY memcpy
+#endif
+
+ .machine power8
+ENTRY_TOCLESS (MEMCPY, 5)
+ CALL_MCOUNT 3
+
+ cmpldi 7,5,15
+ bgt 7,L(copy_gt_32)
+ andi. 9,5,0x1
+ mr 9,3
+ beq 0,1f
+ lbz 10,0(4)
+ addi 9,3,1
+ addi 4,4,1
+ stb 10,0(3)
+1:
+ andi. 10,5,0x2
+ beq 0,2f
+ lhz 10,0(4)
+ addi 9,9,2
+ addi 4,4,2
+ sth 10,-2(9)
+2:
+ andi. 10,5,0x4
+ beq 0,3f
+ lwz 10,0(4)
+ addi 9,9,4
+ addi 4,4,4
+ stw 10,-4(9)
+3:
+ andi. 10,5,0x8
+ beqlr 0
+ ld 10,0(4)
+ std 10,0(9)
+ blr
+
+ .align 4
+L(copy_gt_32):
+ cmpldi 7,5,32
+ ble 7,L(copy_gt_16_le_32)
+ cmpldi 7,5,64
+ ble 7,L(copy_gt_32_le_64)
+ cmpldi 7,5,127
+ mr 9,3
+ ble 7,L(copy_gt_64_le_128)
+ addi 8,5,-128
+ li 11,16
+ rldicr 8,8,0,56
+ li 6,32
+ srdi 10,8,7
+ addi 0,8,128
+ addi 10,10,1
+ li 7,48
+ mtctr 10
+
+ .align 4
+L(copy_128):
+ lxvd2x 10,0,4
+ lxvd2x 11,4,11
+ addi 8,4,64
+ addi 10,9,64
+ lxvd2x 12,4,6
+ lxvd2x 0,4,7
+ addi 4,4,128
+ stxvd2x 10,0,9
+ stxvd2x 11,9,11
+ stxvd2x 12,9,6
+ stxvd2x 0,9,7
+ addi 9,9,128
+ lxvd2x 10,0,8
+ lxvd2x 11,8,11
+ lxvd2x 12,8,6
+ lxvd2x 0,8,7
+ stxvd2x 10,0,10
+ stxvd2x 11,10,11
+ stxvd2x 12,10,6
+ stxvd2x 0,10,7
+ bdnz L(copy_128)
+ add 9,3,0
+ rldicl 5,5,0,57
+L(copy_gt_64_le_128):
+ cmpldi 7,5,63
+ ble 7,L(copy_tail_le_64)
+ li 7,16
+ li 8,32
+ lxvd2x 10,0,4
+ li 10,48
+ addi 5,5,-64
+ lxvd2x 11,4,7
+ lxvd2x 12,4,8
+ lxvd2x 0,4,10
+ addi 4,4,64
+ stxvd2x 10,0,9
+ stxvd2x 11,9,7
+ stxvd2x 12,9,8
+ stxvd2x 0,9,10
+ addi 9,9,64
+L(copy_tail_le_64):
+ cmpldi 7,5,32
+ bgt 7,L(copy_tail_gt_32_le_64)
+ cmpdi 7,5,0
+ beqlr 7
+ addi 5,5,-32
+ li 10,16
+ add 7,4,5
+ add 8,9,5
+ lxvd2x 12,4,5
+ lxvd2x 0,7,10
+ stxvd2x 12,9,5
+ stxvd2x 0,8,10
+ blr
+
+ .align 4
+L(copy_gt_16_le_32):
+ lxvd2x 0,0,4
+ addi 5,5,-16
+ lxvd2x 12,4,5
+ stxvd2x 0,0,3
+ stxvd2x 12,3,5
+ blr
+
+ .align 4
+L(copy_gt_32_le_64):
+ li 9,16
+ lxvd2x 12,0,4
+ addi 5,5,-32
+ add 8,4,5
+ add 10,3,5
+ lxvd2x 0,4,9
+ stxvd2x 12,0,3
+ stxvd2x 0,3,9
+ lxvd2x 12,4,5
+ lxvd2x 0,8,9
+ stxvd2x 12,3,5
+ stxvd2x 0,10,9
+ blr
+
+ .align 4
+L(copy_tail_gt_32_le_64):
+ li 10,16
+ lxvd2x 12,0,4
+ addi 5,5,-32
+ add 7,4,5
+ add 8,9,5
+ lxvd2x 0,4,10
+ stxvd2x 12,0,9
+ stxvd2x 0,9,10
+ lxvd2x 12,4,5
+ lxvd2x 0,7,10
+ stxvd2x 12,9,5
+ stxvd2x 0,8,10
+ blr
+
+END_GEN_TB (MEMCPY,TB_TOCLESS)
+libc_hidden_builtin_def (memcpy)
-----------------------------------------------------------------------
hooks/post-receive
--
GNU C Library master sources