diff options
author | Damjan Marion <damarion@cisco.com> | 2018-05-19 00:04:23 +0200 |
---|---|---|
committer | Damjan Marion <damarion@cisco.com> | 2018-05-20 14:52:39 +0200 |
commit | a52e1668c9976bd5cdd20d02b668df41ea41f16f (patch) | |
tree | 75ed44c2df7a88e0e3af39ae1c4de4cc49f36ad7 /src/vppinfra/vector.h | |
parent | 3b854a5cb876b5af4e69c56028e2c2824100f4b2 (diff) |
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 <damarion@cisco.com>
Diffstat (limited to 'src/vppinfra/vector.h')
-rw-r--r-- | src/vppinfra/vector.h | 59 |
1 files changed, 18 insertions, 41 deletions
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 <vppinfra/vector_sse42.h> #endif @@ -222,6 +181,24 @@ t##s##x##c##_splat (t##s x) \ #include <vppinfra/vector_funcs.h> #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 */ |