diff options
author | Damjan Marion <damarion@cisco.com> | 2019-03-13 12:41:54 +0100 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2019-03-13 16:44:13 +0000 |
commit | 3e94c419e3398e0c030ed0d3d3c72cac38397fe6 (patch) | |
tree | 69676d9c054e82bc8073e2bc0b6af6817ca45c5c /src/vlib | |
parent | 7e5735d31274ed281aba9785667c2472cacdcc5f (diff) |
buffers: don't use clib_memcpy for copying buffer indices
Should be faster this way if n_indices is not constant value
Change-Id: I6c34fd313daa2392199f3b9bd20d0cd6cf9ae21b
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vlib')
-rw-r--r-- | src/vlib/buffer_funcs.h | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/src/vlib/buffer_funcs.h b/src/vlib/buffer_funcs.h index cc16fa71a76..f2ac0bd92dd 100644 --- a/src/vlib/buffer_funcs.h +++ b/src/vlib/buffer_funcs.h @@ -101,7 +101,43 @@ vlib_buffer_get_default_data_size (vlib_main_t * vm) static_always_inline void vlib_buffer_copy_indices (u32 * dst, u32 * src, u32 n_indices) { - clib_memcpy_fast (dst, src, n_indices * sizeof (u32)); +#if defined(CLIB_HAVE_VEC512) + while (n_indices >= 16) + { + u32x16_store_unaligned (u32x16_load_unaligned (src), dst); + dst += 16; + src += 16; + n_indices -= 16; + } +#endif + +#if defined(CLIB_HAVE_VEC256) + while (n_indices >= 8) + { + u32x8_store_unaligned (u32x8_load_unaligned (src), dst); + dst += 8; + src += 8; + n_indices -= 8; + } +#endif + +#if defined(CLIB_HAVE_VEC128) + while (n_indices >= 4) + { + u32x4_store_unaligned (u32x4_load_unaligned (src), dst); + dst += 4; + src += 4; + n_indices -= 4; + } +#endif + + while (n_indices) + { + dst[0] = src[0]; + dst += 1; + src += 1; + n_indices -= 1; + } } STATIC_ASSERT_OFFSET_OF (vlib_buffer_t, template_end, 64); |