From a52e1668c9976bd5cdd20d02b668df41ea41f16f Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Sat, 19 May 2018 00:04:23 +0200 Subject: vector functions cleanup and improvements Remove functions which have native C equivalent (i.e. _is_equal can be replaced with ==, _add with +) Add SSE4.2, AVX-512 implementations of splat, load_unaligned, store_unaligned, is_all_zero, is_equal, is_all_equal Change-Id: Ie80b0e482e7a76248ad79399c2576468532354cd Signed-off-by: Damjan Marion --- src/vppinfra/vector.h | 59 ++++++++++++++++----------------------------------- 1 file changed, 18 insertions(+), 41 deletions(-) (limited to 'src/vppinfra/vector.h') diff --git a/src/vppinfra/vector.h b/src/vppinfra/vector.h index fcff5e79d95..2157ab7d1d0 100644 --- a/src/vppinfra/vector.h +++ b/src/vppinfra/vector.h @@ -157,47 +157,6 @@ typedef u64 u64x _vector_size (8); #define VECTOR_WORD_TYPE(t) t##x #define VECTOR_WORD_TYPE_LEN(t) (sizeof (VECTOR_WORD_TYPE(t)) / sizeof (t)) -/* this series of macros generate _is_equal, _is_greater, _is_zero, _add - and _sub inline funcitons for each vector type */ -#define _(t, s, c) \ - static_always_inline t##s##x##c \ -t##s##x##c##_is_equal (t##s##x##c v1, t##s##x##c v2) \ -{ return (v1 == v2); } \ - \ -static_always_inline t##s##x##c \ -t##s##x##c##_is_greater (t##s##x##c v1, t##s##x##c v2) \ -{ return (v1 > v2); } \ - \ -static_always_inline t##s##x##c \ -t##s##x##c##_is_zero (t##s##x##c v1) \ -{ t##s##x##c z = {0}; return (v1 == z); } \ - \ -static_always_inline t##s##x##c \ -t##s##x##c##_add (t##s##x##c v1, t##s##x##c v2) \ -{ return (v1 + v2); } \ - \ -static_always_inline t##s##x##c \ -t##s##x##c##_sub (t##s##x##c v1, t##s##x##c v2) \ -{ return (v1 - v2); } - foreach_vec -#undef _ - -/* this macro generate _splat inline functions for each scalar vector type */ -#define _(t, s, c) \ - static_always_inline t##s##x##c \ -t##s##x##c##_splat (t##s x) \ -{ \ - t##s##x##c r; \ - int i; \ - \ - for (i = 0; i < c; i++) \ - r[i] = x; \ - \ - return r; \ -} - foreach_vec128i foreach_vec128u -#undef _ - #if defined (__SSE4_2__) && __GNUC__ >= 4 #include #endif @@ -222,6 +181,24 @@ t##s##x##c##_splat (t##s x) \ #include #endif +/* this macro generate _splat inline functions for each scalar vector type */ +#ifndef CLIB_VEC128_SPLAT_DEFINED +#define _(t, s, c) \ + static_always_inline t##s##x##c \ +t##s##x##c##_splat (t##s x) \ +{ \ + t##s##x##c r; \ + int i; \ + \ + for (i = 0; i < c; i++) \ + r[i] = x; \ + \ + return r; \ +} + foreach_vec128i foreach_vec128u +#undef _ +#endif + /* *INDENT-ON* */ #endif /* included_clib_vector_h */ -- cgit 1.2.3-korg