This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] x86_64: memset optimized with AVX512
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Andrew Senkevich <andrew dot n dot senkevich at gmail dot com>
- Cc: libc-alpha <libc-alpha at sourceware dot org>
- Date: Thu, 3 Dec 2015 13:21:27 -0800
- Subject: Re: [PATCH] x86_64: memset optimized with AVX512
- Authentication-results: sourceware.org; auth=none
- References: <CAMXFM3v7K1bO8aUB=rVBzKqAZJuNrMBh5NuyszONtB-sZrXcgA at mail dot gmail dot com>
On Thu, Dec 3, 2015 at 12:46 PM, Andrew Senkevich
<andrew.n.senkevich@gmail.com> wrote:
> Hi,
>
> here is AVX512 memset implementation.
> It is faster enough than AVX2 memset on KNL hardware, performance
> results attached.
>
> 2015-12-03 Andrew Senkevich <andrew.senkevich@intel.com>
>
> * sysdeps/x86_64/multiarch/Makefile: Added new file.
> * sysdeps/x86_64/multiarch/ifunc-impl-list.c: Added test.
> * sysdeps/x86_64/multiarch/memset-avx512.S: New file.
> * sysdeps/x86_64/multiarch/memset.S: Added new IFUNC branch.
> * sysdeps/x86_64/multiarch/memset-avx2.S: Added libc_hidden_def for
> __memset_avx2.
>
> diff --git a/sysdeps/x86_64/multiarch/Makefile
> b/sysdeps/x86_64/multiarch/Makefile
> index bb811c2..5bb859e 100644
> --- a/sysdeps/x86_64/multiarch/Makefile
> +++ b/sysdeps/x86_64/multiarch/Makefile
> @@ -18,7 +18,7 @@ sysdep_routines += strncat-c stpncpy-c strncpy-c
> strcmp-ssse3 \
> stpcpy-sse2-unaligned stpncpy-sse2-unaligned \
> strcat-sse2-unaligned strncat-sse2-unaligned \
> strchr-sse2-no-bsf memcmp-ssse3 strstr-sse2-unaligned \
> - strcspn-c strpbrk-c strspn-c varshift memset-avx2
> + strcspn-c strpbrk-c strspn-c varshift memset-avx2
> memset-avx512
> CFLAGS-varshift.c += -msse4
> CFLAGS-strcspn-c.c += -msse4
> CFLAGS-strpbrk-c.c += -msse4
> diff --git a/sysdeps/x86_64/multiarch/ifunc-impl-list.c
> b/sysdeps/x86_64/multiarch/ifunc-impl-list.c
> index 5c0c219..a8be3eb 100644
> --- a/sysdeps/x86_64/multiarch/ifunc-impl-list.c
> +++ b/sysdeps/x86_64/multiarch/ifunc-impl-list.c
> @@ -83,7 +83,10 @@ __libc_ifunc_impl_list (const char *name, struct
> libc_ifunc_impl *array,
> IFUNC_IMPL_ADD (array, i, memset, 1, __memset_sse2)
> IFUNC_IMPL_ADD (array, i, memset,
> HAS_ARCH_FEATURE (AVX2_Usable),
> - __memset_avx2))
> + __memset_avx2)
> + IFUNC_IMPL_ADD (array, i, memset,
> + HAS_ARCH_FEATURE (AVX512F_Usable),
> + __memset_avx512))
>
> /* Support sysdeps/x86_64/multiarch/stpncpy.S. */
> IFUNC_IMPL (i, name, stpncpy,
> diff --git a/sysdeps/x86_64/multiarch/memset-avx2.S
> b/sysdeps/x86_64/multiarch/memset-avx2.S
> index 28eabad..f96baf3 100644
> --- a/sysdeps/x86_64/multiarch/memset-avx2.S
> +++ b/sysdeps/x86_64/multiarch/memset-avx2.S
> @@ -165,4 +165,6 @@ L(gobble_data):
> ret
>
> END (MEMSET)
> +libc_hidden_def (__memset_avx2)
Why is this change needed? If it is needed, please submit
a separate patch.
> +
> #endif
> diff --git a/sysdeps/x86_64/multiarch/memset-avx512.S
> b/sysdeps/x86_64/multiarch/memset-avx512.S
> new file mode 100644
> index 0000000..083177e
> --- /dev/null
> +++ b/sysdeps/x86_64/multiarch/memset-avx512.S
> @@ -0,0 +1,191 @@
> +/* memset optimized with AVX512.
> + 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>
> +
> +#if IS_IN (libc)
> +
> +#include "asm-syntax.h"
> +#ifndef MEMSET
> +# define MEMSET __memset_avx512
> +#endif
> +
Should __memset_chk_avx512 also be provided?
--
H.J.