From b46334bf0564036a90a232fa36987842ebca7582 Mon Sep 17 00:00:00 2001 From: Benoît Ganne Date: Mon, 21 Mar 2022 15:02:21 +0100 Subject: vppinfra: use AVX512 compare for equality testing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit only update is_equal flavours to use _mm512_cmpneq_epi64_mask() but clang-format decided to also reformat the whole block. Type: improvement Change-Id: I530cf91e8bceaf15022556f803b27de4f8583217 Signed-off-by: Benoît Ganne --- src/vppinfra/vector_avx512.h | 104 ++++++++++++++++++++++++------------------- 1 file changed, 59 insertions(+), 45 deletions(-) (limited to 'src/vppinfra/vector_avx512.h') diff --git a/src/vppinfra/vector_avx512.h b/src/vppinfra/vector_avx512.h index e71a8a70aa9..96c78e4c30f 100644 --- a/src/vppinfra/vector_avx512.h +++ b/src/vppinfra/vector_avx512.h @@ -29,51 +29,65 @@ /* splat, load_unaligned, store_unaligned, is_all_zero, is_equal, is_all_equal, is_zero_mask */ -#define _(t, s, c, i) \ -static_always_inline t##s##x##c \ -t##s##x##c##_splat (t##s x) \ -{ return (t##s##x##c) _mm512_set1_##i (x); } \ -\ -static_always_inline t##s##x##c \ -t##s##x##c##_load_aligned (void *p) \ -{ return (t##s##x##c) _mm512_load_si512 (p); } \ -\ -static_always_inline void \ -t##s##x##c##_store_aligned (t##s##x##c v, void *p) \ -{ _mm512_store_si512 ((__m512i *) p, (__m512i) v); } \ -\ -static_always_inline t##s##x##c \ -t##s##x##c##_load_unaligned (void *p) \ -{ return (t##s##x##c) _mm512_loadu_si512 (p); } \ -\ -static_always_inline void \ -t##s##x##c##_store_unaligned (t##s##x##c v, void *p) \ -{ _mm512_storeu_si512 ((__m512i *) p, (__m512i) v); } \ -\ -static_always_inline int \ -t##s##x##c##_is_all_zero (t##s##x##c v) \ -{ return (_mm512_test_epi64_mask ((__m512i) v, (__m512i) v) == 0); } \ -\ -static_always_inline int \ -t##s##x##c##_is_equal (t##s##x##c a, t##s##x##c b) \ -{ return t##s##x##c##_is_all_zero (a ^ b); } \ -\ -static_always_inline int \ -t##s##x##c##_is_all_equal (t##s##x##c v, t##s x) \ -{ return t##s##x##c##_is_equal (v, t##s##x##c##_splat (x)); } \ -\ -static_always_inline u##c \ -t##s##x##c##_is_zero_mask (t##s##x##c v) \ -{ return _mm512_test_##i##_mask ((__m512i) v, (__m512i) v); } \ -\ -static_always_inline t##s##x##c \ -t##s##x##c##_interleave_lo (t##s##x##c a, t##s##x##c b) \ -{ return (t##s##x##c) _mm512_unpacklo_##i ((__m512i) a, (__m512i) b); } \ -\ -static_always_inline t##s##x##c \ -t##s##x##c##_interleave_hi (t##s##x##c a, t##s##x##c b) \ -{ return (t##s##x##c) _mm512_unpackhi_##i ((__m512i) a, (__m512i) b); } \ - +#define _(t, s, c, i) \ + static_always_inline t##s##x##c t##s##x##c##_splat (t##s x) \ + { \ + return (t##s##x##c) _mm512_set1_##i (x); \ + } \ + \ + static_always_inline t##s##x##c t##s##x##c##_load_aligned (void *p) \ + { \ + return (t##s##x##c) _mm512_load_si512 (p); \ + } \ + \ + static_always_inline void t##s##x##c##_store_aligned (t##s##x##c v, \ + void *p) \ + { \ + _mm512_store_si512 ((__m512i *) p, (__m512i) v); \ + } \ + \ + static_always_inline t##s##x##c t##s##x##c##_load_unaligned (void *p) \ + { \ + return (t##s##x##c) _mm512_loadu_si512 (p); \ + } \ + \ + static_always_inline void t##s##x##c##_store_unaligned (t##s##x##c v, \ + void *p) \ + { \ + _mm512_storeu_si512 ((__m512i *) p, (__m512i) v); \ + } \ + \ + static_always_inline int t##s##x##c##_is_all_zero (t##s##x##c v) \ + { \ + return (_mm512_test_epi64_mask ((__m512i) v, (__m512i) v) == 0); \ + } \ + \ + static_always_inline int t##s##x##c##_is_equal (t##s##x##c a, t##s##x##c b) \ + { \ + return (_mm512_cmpneq_epi64_mask ((__m512i) a, (__m512i) b) == 0); \ + } \ + \ + static_always_inline int t##s##x##c##_is_all_equal (t##s##x##c v, t##s x) \ + { \ + return t##s##x##c##_is_equal (v, t##s##x##c##_splat (x)); \ + } \ + \ + static_always_inline u##c t##s##x##c##_is_zero_mask (t##s##x##c v) \ + { \ + return _mm512_test_##i##_mask ((__m512i) v, (__m512i) v); \ + } \ + \ + static_always_inline t##s##x##c t##s##x##c##_interleave_lo (t##s##x##c a, \ + t##s##x##c b) \ + { \ + return (t##s##x##c) _mm512_unpacklo_##i ((__m512i) a, (__m512i) b); \ + } \ + \ + static_always_inline t##s##x##c t##s##x##c##_interleave_hi (t##s##x##c a, \ + t##s##x##c b) \ + { \ + return (t##s##x##c) _mm512_unpackhi_##i ((__m512i) a, (__m512i) b); \ + } foreach_avx512_vec512i foreach_avx512_vec512u #undef _ -- cgit 1.2.3-korg