aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vlib/buffer_funcs.c3
-rw-r--r--src/vnet/interface_output.c3
-rw-r--r--src/vppinfra/CMakeLists.txt9
-rw-r--r--src/vppinfra/vector/compress.h78
-rw-r--r--src/vppinfra/vector/mask_compare.h (renamed from src/vppinfra/vector_funcs.h)72
-rw-r--r--src/vppinfra/vector/test/compress.c (renamed from src/vppinfra/test_vector_funcs_compress.c)4
-rw-r--r--src/vppinfra/vector/test/mask_compare.c (renamed from src/vppinfra/test_vector_funcs_mask_compare.c)4
-rw-r--r--src/vppinfra/vector/test/test.c (renamed from src/vppinfra/test_vector_funcs.c)2
-rw-r--r--src/vppinfra/vector/test/test.h (renamed from src/vppinfra/test_vector_funcs.h)0
9 files changed, 94 insertions, 81 deletions
diff --git a/src/vlib/buffer_funcs.c b/src/vlib/buffer_funcs.c
index 624b6e6b8c7..a661370a141 100644
--- a/src/vlib/buffer_funcs.c
+++ b/src/vlib/buffer_funcs.c
@@ -4,7 +4,8 @@
#include <vppinfra/clib.h>
#include <vlib/vlib.h>
-#include <vppinfra/vector_funcs.h>
+#include <vppinfra/vector/mask_compare.h>
+#include <vppinfra/vector/compress.h>
static_always_inline u32
enqueue_one (vlib_main_t *vm, vlib_node_runtime_t *node, u64 *used_elt_bmp,
diff --git a/src/vnet/interface_output.c b/src/vnet/interface_output.c
index 45669648b64..0de2714ed61 100644
--- a/src/vnet/interface_output.c
+++ b/src/vnet/interface_output.c
@@ -47,7 +47,8 @@
#include <vnet/feature/feature.h>
#include <vnet/classify/pcap_classify.h>
#include <vnet/interface_output.h>
-#include <vppinfra/vector_funcs.h>
+#include <vppinfra/vector/mask_compare.h>
+#include <vppinfra/vector/compress.h>
typedef struct
{
diff --git a/src/vppinfra/CMakeLists.txt b/src/vppinfra/CMakeLists.txt
index 64420b96676..8f9d0746b42 100644
--- a/src/vppinfra/CMakeLists.txt
+++ b/src/vppinfra/CMakeLists.txt
@@ -188,7 +188,8 @@ set(VPPINFRA_HEADERS
vector_altivec.h
vector_avx2.h
vector_avx512.h
- vector_funcs.h
+ vector/mask_compare.h
+ vector/compress.h
vector.h
vector_neon.h
vector_sse42.h
@@ -264,13 +265,13 @@ if(VPP_BUILD_VPPINFRA_TESTS)
endforeach()
set(test_files
- test_vector_funcs_compress.c
- test_vector_funcs_mask_compare.c
+ vector/test/compress.c
+ vector/test/mask_compare.c
)
add_vpp_executable(test_vector_funcs
SOURCES
- test_vector_funcs.c
+ vector/test/test.c
${test_files}
LINK_LIBRARIES vppinfra
)
diff --git a/src/vppinfra/vector/compress.h b/src/vppinfra/vector/compress.h
new file mode 100644
index 00000000000..1d5d84e77ea
--- /dev/null
+++ b/src/vppinfra/vector/compress.h
@@ -0,0 +1,78 @@
+/* SPDX-License-Identifier: Apache-2.0
+ * Copyright(c) 2021 Cisco Systems, Inc.
+ */
+
+#ifndef included_vector_compress_h
+#define included_vector_compress_h
+#include <vppinfra/clib.h>
+#include <vppinfra/memcpy.h>
+
+static_always_inline u32 *
+clib_compress_u32_x64 (u32 *dst, u32 *src, u64 mask)
+{
+#if defined(CLIB_HAVE_VEC512_COMPRESS)
+ u32x16u *sv = (u32x16u *) src;
+ for (int i = 0; i < 4; i++)
+ {
+ int cnt = _popcnt32 ((u16) mask);
+ u32x16_compress_store (sv[i], mask, dst);
+ dst += cnt;
+ mask >>= 16;
+ }
+
+#elif defined(CLIB_HAVE_VEC256_COMPRESS)
+ u32x8u *sv = (u32x8u *) src;
+ for (int i = 0; i < 8; i++)
+ {
+ int cnt = _popcnt32 ((u8) mask);
+ u32x8_compress_store (sv[i], mask, dst);
+ dst += cnt;
+ mask >>= 8;
+ }
+#else
+ while (mask)
+ {
+ u16 bit = count_trailing_zeros (mask);
+ mask = clear_lowest_set_bit (mask);
+ dst++[0] = src[bit];
+ }
+#endif
+ return dst;
+}
+
+/** \brief Compress array of 32-bit elemments into destination array based on
+ * mask
+
+ @param dst destination array of u32 elements
+ @param src source array of u32 elements
+ @param mask array of u64 values representing compress mask
+ @param n_elts number of elements in the source array
+ @return number of elements stored in destionation array
+*/
+
+static_always_inline u32
+clib_compress_u32 (u32 *dst, u32 *src, u64 *mask, u32 n_elts)
+{
+ u32 *dst0 = dst;
+ while (n_elts >= 64)
+ {
+ if (mask[0] == ~0ULL)
+ {
+ clib_memcpy_u32 (dst, src, 64);
+ dst += 64;
+ }
+ else
+ dst = clib_compress_u32_x64 (dst, src, mask[0]);
+
+ mask++;
+ src += 64;
+ n_elts -= 64;
+ }
+
+ if (PREDICT_TRUE (n_elts == 0))
+ return dst - dst0;
+
+ return clib_compress_u32_x64 (dst, src, mask[0] & pow2_mask (n_elts)) - dst0;
+}
+
+#endif
diff --git a/src/vppinfra/vector_funcs.h b/src/vppinfra/vector/mask_compare.h
index fed1b5cc3d8..cac48a31f47 100644
--- a/src/vppinfra/vector_funcs.h
+++ b/src/vppinfra/vector/mask_compare.h
@@ -2,8 +2,8 @@
* Copyright(c) 2021 Cisco Systems, Inc.
*/
-#ifndef included_vector_funcs_h
-#define included_vector_funcs_h
+#ifndef included_vector_mask_compare_h
+#define included_vector_mask_compare_h
#include <vppinfra/clib.h>
#include <vppinfra/memcpy.h>
@@ -163,72 +163,4 @@ clib_mask_compare_u32 (u32 v, u32 *a, u64 *bitmap, u32 n_elts)
bitmap[0] = clib_mask_compare_u32_x64 (v, a, n_elts) & pow2_mask (n_elts);
}
-static_always_inline u32 *
-clib_compress_u32_x64 (u32 *dst, u32 *src, u64 mask)
-{
-#if defined(CLIB_HAVE_VEC512_COMPRESS)
- u32x16u *sv = (u32x16u *) src;
- for (int i = 0; i < 4; i++)
- {
- int cnt = _popcnt32 ((u16) mask);
- u32x16_compress_store (sv[i], mask, dst);
- dst += cnt;
- mask >>= 16;
- }
-
-#elif defined(CLIB_HAVE_VEC256_COMPRESS)
- u32x8u *sv = (u32x8u *) src;
- for (int i = 0; i < 8; i++)
- {
- int cnt = _popcnt32 ((u8) mask);
- u32x8_compress_store (sv[i], mask, dst);
- dst += cnt;
- mask >>= 8;
- }
-#else
- while (mask)
- {
- u16 bit = count_trailing_zeros (mask);
- mask = clear_lowest_set_bit (mask);
- dst++[0] = src[bit];
- }
-#endif
- return dst;
-}
-
-/** \brief Compare array of 32-bit elemments into destination array based on
- * mask
-
- @param dst destination array of u32 elements
- @param src source array of u32 elements
- @param mask array of u64 values representing compress mask
- @param n_elts number of elements in the source array
- @return number of elements stored in destionation array
-*/
-
-static_always_inline u32
-clib_compress_u32 (u32 *dst, u32 *src, u64 *mask, u32 n_elts)
-{
- u32 *dst0 = dst;
- while (n_elts >= 64)
- {
- if (mask[0] == ~0ULL)
- {
- clib_memcpy_u32 (dst, src, 64);
- dst += 64;
- }
- else
- dst = clib_compress_u32_x64 (dst, src, mask[0]);
-
- mask++;
- src += 64;
- n_elts -= 64;
- }
-
- if (PREDICT_TRUE (n_elts == 0))
- return dst - dst0;
-
- return clib_compress_u32_x64 (dst, src, mask[0] & pow2_mask (n_elts)) - dst0;
-}
-
#endif
diff --git a/src/vppinfra/test_vector_funcs_compress.c b/src/vppinfra/vector/test/compress.c
index c0815601e45..7e3eba9892d 100644
--- a/src/vppinfra/test_vector_funcs_compress.c
+++ b/src/vppinfra/vector/test/compress.c
@@ -3,8 +3,8 @@
*/
#include <vppinfra/format.h>
-#include <vppinfra/vector_funcs.h>
-#include <vppinfra/test_vector_funcs.h>
+#include <vppinfra/vector/test/test.h>
+#include <vppinfra/vector/compress.h>
__clib_test_fn u32
clib_compress_u32_wrapper (u32 *dst, u32 *src, u64 *mask, u32 n_elts)
diff --git a/src/vppinfra/test_vector_funcs_mask_compare.c b/src/vppinfra/vector/test/mask_compare.c
index 009f87712e4..64df0ee084a 100644
--- a/src/vppinfra/test_vector_funcs_mask_compare.c
+++ b/src/vppinfra/vector/test/mask_compare.c
@@ -3,8 +3,8 @@
*/
#include <vppinfra/format.h>
-#include <vppinfra/vector_funcs.h>
-#include <vppinfra/test_vector_funcs.h>
+#include <vppinfra/vector/test/test.h>
+#include <vppinfra/vector/mask_compare.h>
__clib_test_fn void
clib_mask_compare_u16_wrapper (u16 v, u16 *a, u64 *mask, u32 n_elts)
diff --git a/src/vppinfra/test_vector_funcs.c b/src/vppinfra/vector/test/test.c
index 85f159a17c6..0e90bacce49 100644
--- a/src/vppinfra/test_vector_funcs.c
+++ b/src/vppinfra/vector/test/test.c
@@ -3,7 +3,7 @@
*/
#include <vppinfra/format.h>
-#include <vppinfra/test_vector_funcs.h>
+#include <vppinfra/vector/test/test.h>
test_registration_t *test_registrations[CLIB_MARCH_TYPE_N_VARIANTS] = {};
diff --git a/src/vppinfra/test_vector_funcs.h b/src/vppinfra/vector/test/test.h
index bc499fb24e8..bc499fb24e8 100644
--- a/src/vppinfra/test_vector_funcs.h
+++ b/src/vppinfra/vector/test/test.h