aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2018-06-26 01:29:55 +0200
committerDamjan Marion <damarion@cisco.com>2018-06-26 12:08:02 +0200
commit32ab95426d40920c526f0de89a43f88819616ed8 (patch)
tree303d87264698840a822b5c0fd2fb40b6bf256670 /src
parent0131b6c438e1e7ccc41c9abd1f02ac398d34dfaa (diff)
SIMD optimized linear search in clib_bitmap_first_set
Change-Id: Ib3a55598a83cc99485b40e38e7c406ecb126fd42 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/vppinfra/bitmap.h25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/vppinfra/bitmap.h b/src/vppinfra/bitmap.h
index dbf9eeb2232..9418b1fcced 100644
--- a/src/vppinfra/bitmap.h
+++ b/src/vppinfra/bitmap.h
@@ -384,8 +384,29 @@ do { \
always_inline uword
clib_bitmap_first_set (uword * ai)
{
- uword i;
- for (i = 0; i < vec_len (ai); i++)
+ uword i = 0;
+#if uword_bits == 64
+#if defined (CLIB_HAVE_VEC256)
+ while (i + 7 < vec_len (ai))
+ {
+ u64x4 v;
+ v = u64x4_load_unaligned (ai + i) | u64x4_load_unaligned (ai + i + 4);
+ if (!u64x4_is_all_zero (v))
+ break;
+ i += 8;
+ }
+#elif defined (CLIB_HAVE_VEC128)
+ while (i + 3 < vec_len (ai))
+ {
+ u64x2 v;
+ v = u64x2_load_unaligned (ai + i) | u64x2_load_unaligned (ai + i + 2);
+ if (!u64x2_is_all_zero (v))
+ break;
+ i += 4;
+ }
+#endif
+#endif
+ for (; i < vec_len (ai); i++)
{
uword x = ai[i];
if (x != 0)