glibc/sysdeps
H.J. Lu fb0f7a6755 X86-64: Add _dl_runtime_resolve_avx[512]_{opt|slow} [BZ #20508]
There is transition penalty when SSE instructions are mixed with 256-bit
AVX or 512-bit AVX512 load instructions.  Since _dl_runtime_resolve_avx
and _dl_runtime_profile_avx512 save/restore 256-bit YMM/512-bit ZMM
registers, there is transition penalty when SSE instructions are used
with lazy binding on AVX and AVX512 processors.

To avoid SSE transition penalty, if only the lower 128 bits of the first
8 vector registers are non-zero, we can preserve %xmm0 - %xmm7 registers
with the zero upper bits.

For AVX and AVX512 processors which support XGETBV with ECX == 1, we can
use XGETBV with ECX == 1 to check if the upper 128 bits of YMM registers
or the upper 256 bits of ZMM registers are zero.  We can restore only the
non-zero portion of vector registers with AVX/AVX512 load instructions
which will zero-extend upper bits of vector registers.

This patch adds _dl_runtime_resolve_sse_vex which saves and restores
XMM registers with 128-bit AVX store/load instructions.  It is used to
preserve YMM/ZMM registers when only the lower 128 bits are non-zero.
_dl_runtime_resolve_avx_opt and _dl_runtime_resolve_avx512_opt are added
and used on AVX/AVX512 processors supporting XGETBV with ECX == 1 so
that we store and load only the non-zero portion of vector registers.
This avoids SSE transition penalty caused by _dl_runtime_resolve_avx and
_dl_runtime_profile_avx512 when only the lower 128 bits of vector
registers are used.

_dl_runtime_resolve_avx_slow is added and used for AVX processors which
don't support XGETBV with ECX == 1.  Since there is no SSE transition
penalty on AVX512 processors which don't support XGETBV with ECX == 1,
_dl_runtime_resolve_avx512_slow isn't provided.

	[BZ #20495]
	[BZ #20508]
	* sysdeps/x86/cpu-features.c (init_cpu_features): For Intel
	processors, set Use_dl_runtime_resolve_slow and set
	Use_dl_runtime_resolve_opt if XGETBV suports ECX == 1.
	* sysdeps/x86/cpu-features.h (bit_arch_Use_dl_runtime_resolve_opt):
	New.
	(bit_arch_Use_dl_runtime_resolve_slow): Likewise.
	(index_arch_Use_dl_runtime_resolve_opt): Likewise.
	(index_arch_Use_dl_runtime_resolve_slow): Likewise.
	* sysdeps/x86_64/dl-machine.h (elf_machine_runtime_setup): Use
	_dl_runtime_resolve_avx512_opt and _dl_runtime_resolve_avx_opt
	if Use_dl_runtime_resolve_opt is set.  Use
	_dl_runtime_resolve_slow if Use_dl_runtime_resolve_slow is set.
	* sysdeps/x86_64/dl-trampoline.S: Include <cpu-features.h>.
	(_dl_runtime_resolve_opt): New.  Defined for AVX and AVX512.
	(_dl_runtime_resolve): Add one for _dl_runtime_resolve_sse_vex.
	* sysdeps/x86_64/dl-trampoline.h (_dl_runtime_resolve_avx_slow):
	New.
	(_dl_runtime_resolve_opt): Likewise.
	(_dl_runtime_profile): Define only if _dl_runtime_profile is
	defined.
2016-09-06 08:51:07 -07:00
..
aarch64 Make common fmax implementation generic. 2016-09-01 09:31:05 -05:00
alpha Convert remaining complex function to generated files 2016-08-29 12:43:38 -05:00
arm Add fesetexcept: arm. 2016-08-16 16:18:24 +00:00
generic Remove unneeded stubs for k_rem_pio2l. 2016-09-01 09:31:06 -05:00
gnu Define UDP_ENCAP_* from Linux 4.7 in netinet/udp.h. 2016-08-03 12:13:16 +00:00
hppa Add fesetexcept: hppa. 2016-08-16 16:19:03 +00:00
i386 Remove unneeded stubs for k_rem_pio2l. 2016-09-01 09:31:06 -05:00
ia64 Remove unneeded stubs for k_rem_pio2l. 2016-09-01 09:31:06 -05:00
ieee754 Inline all support functions for sin and cos 2016-09-02 20:08:41 +05:30
init_array Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
m68k Remove unneeded stubs for k_rem_pio2l. 2016-09-01 09:31:06 -05:00
mach hurd: Fix adjtime call with OLDDELTA == NULL 2016-08-30 23:07:30 +02:00
microblaze Remove atomic_compare_and_exchange_bool_rel. 2016-06-24 23:04:40 +03:00
mips Do not override objects in libc.a in other static libraries [BZ #20452] 2016-08-17 14:57:01 +02:00
nacl NaCl: Fix compile error for __dup after libc_hidden_proto addition. 2016-09-02 16:58:42 -07:00
nios2 elf: Consolidate machine-agnostic DTV definitions in <dl-dtv.h> 2016-06-20 14:31:40 +02:00
nptl malloc: Simplify static malloc interposition [BZ #20432] 2016-08-26 23:20:41 +02:00
posix Fix generic wait3 after union wait_status removal. 2016-09-02 16:57:59 -07:00
powerpc Add fesetexcept: powerpc. 2016-08-16 16:22:12 +00:00
pthread Revert "aio: fix newp->running data race" 2016-05-04 15:52:30 +02:00
s390 S390: Do not set FE_INEXACT with feraiseexcept (FE_OWERFLOW|FE_UNDERFLOW). 2016-08-31 14:54:55 +02:00
sh Add fesetexcept: sh. 2016-08-16 16:25:10 +00:00
sparc Make common fdim implementation generic. 2016-09-01 09:28:05 -05:00
tile Remove atomic_compare_and_exchange_bool_rel. 2016-06-24 23:04:40 +03:00
unix S390: Support PLT and GOT references in check-localplt. 2016-09-06 14:44:15 +02:00
wordsize-32 Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
wordsize-64 Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
x86 X86-64: Add _dl_runtime_resolve_avx[512]_{opt|slow} [BZ #20508] 2016-09-06 08:51:07 -07:00
x86_64 X86-64: Add _dl_runtime_resolve_avx[512]_{opt|slow} [BZ #20508] 2016-09-06 08:51:07 -07:00