aboutsummaryrefslogtreecommitdiffstats
path: root/src/vppinfra/vector_avx512.h
diff options
context:
space:
mode:
authorBenoît Ganne <bganne@cisco.com>2022-03-21 15:02:21 +0100
committerDamjan Marion <dmarion@me.com>2022-04-05 11:36:42 +0000
commitb46334bf0564036a90a232fa36987842ebca7582 (patch)
tree2dec2cc01f2f8af0ad0d3684a1567a9f49d0366e /src/vppinfra/vector_avx512.h
parent3ce1d14e1fc005315bccfa6f9467487166644538 (diff)
vppinfra: use AVX512 compare for equality testing
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 <bganne@cisco.com>
Diffstat (limited to 'src/vppinfra/vector_avx512.h')
-rw-r--r--src/vppinfra/vector_avx512.h104
1 files changed, 59 insertions, 45 deletions
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 _