From 165986f54ca699c5fabf755fc4706729da95d15c Mon Sep 17 00:00:00 2001 From: Ash Vardanian <1983160+ashvardanian@users.noreply.github.com> Date: Sat, 12 Oct 2024 17:58:53 +0000 Subject: [PATCH] Fix: Explicit `simsimd_size_t` cast in SVE --- include/stringzilla/stringzilla.h | 16 ++++++++-------- scripts/test.cpp | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/stringzilla/stringzilla.h b/include/stringzilla/stringzilla.h index 84f4f55..967dc2f 100644 --- a/include/stringzilla/stringzilla.h +++ b/include/stringzilla/stringzilla.h @@ -6081,7 +6081,7 @@ SZ_PUBLIC void sz_fill_sve(sz_ptr_t target, sz_size_t length, sz_u8_t value) { if (length <= vec_len) { // Small buffer case: use mask to handle small writes - svbool_t mask = svwhilelt_b8(0ull, length); + svbool_t mask = svwhilelt_b8((sz_size_t)0ull, length); svst1_u8(mask, (unsigned char *)target, value_vec); } else { @@ -6091,7 +6091,7 @@ SZ_PUBLIC void sz_fill_sve(sz_ptr_t target, sz_size_t length, sz_u8_t value) { sz_size_t body_length = length - head_length - tail_length; // Handle unaligned head - svbool_t head_mask = svwhilelt_b8(0ull, head_length); + svbool_t head_mask = svwhilelt_b8((sz_size_t)0ull, head_length); svst1_u8(head_mask, (unsigned char *)target, value_vec); target += head_length; @@ -6101,7 +6101,7 @@ SZ_PUBLIC void sz_fill_sve(sz_ptr_t target, sz_size_t length, sz_u8_t value) { } // Handle unaligned tail - svbool_t tail_mask = svwhilelt_b8(0ull, tail_length); + svbool_t tail_mask = svwhilelt_b8((sz_size_t)0ull, tail_length); svst1_u8(tail_mask, (unsigned char *)target, value_vec); } } @@ -6118,7 +6118,7 @@ SZ_PUBLIC void sz_copy_sve(sz_ptr_t target, sz_cptr_t source, sz_size_t length) // When the buffer is small, there isn't much to innovate. if (length <= vec_len) { // Small buffer case: use mask to handle small writes - svbool_t mask = svwhilelt_b8(0ull, length); + svbool_t mask = svwhilelt_b8((sz_size_t)0ull, length); svuint8_t data = svld1_u8(mask, (unsigned char *)source); svst1_u8(mask, (unsigned char *)target, data); } @@ -6143,10 +6143,10 @@ SZ_PUBLIC void sz_copy_sve(sz_ptr_t target, sz_cptr_t source, sz_size_t length) sz_size_t body_length = length - head_length - tail_length; // Handle unaligned parts - svbool_t head_mask = svwhilelt_b8(0ull, head_length); + svbool_t head_mask = svwhilelt_b8((sz_size_t)0ull, head_length); svuint8_t head_data = svld1_u8(head_mask, (unsigned char *)source); svst1_u8(head_mask, (unsigned char *)target, head_data); - svbool_t tail_mask = svwhilelt_b8(0ull, tail_length); + svbool_t tail_mask = svwhilelt_b8((sz_size_t)0ull, tail_length); svuint8_t tail_data = svld1_u8(tail_mask, (unsigned char *)source + head_length + body_length); svst1_u8(tail_mask, (unsigned char *)target + head_length + body_length, tail_data); target += head_length; @@ -6162,7 +6162,7 @@ SZ_PUBLIC void sz_copy_sve(sz_ptr_t target, sz_cptr_t source, sz_size_t length) // Up to (vec_len * 2 - 1) bytes of data may be left in the body, // so we can unroll the last two optional loop iterations. if (body_length > vec_len) { - svbool_t mask = svwhilelt_b8(0ull, body_length); + svbool_t mask = svwhilelt_b8((sz_size_t)0ull, body_length); svuint8_t data = svld1_u8(mask, (unsigned char *)source); svst1_u8(mask, (unsigned char *)target, data); body_length -= vec_len; @@ -6170,7 +6170,7 @@ SZ_PUBLIC void sz_copy_sve(sz_ptr_t target, sz_cptr_t source, sz_size_t length) target += body_length; } if (body_length) { - svbool_t mask = svwhilelt_b8(0ull, body_length); + svbool_t mask = svwhilelt_b8((sz_size_t)0ull, body_length); svuint8_t data = svld1_u8(mask, (unsigned char *)source); svst1_u8(mask, (unsigned char *)target, data); } diff --git a/scripts/test.cpp b/scripts/test.cpp index 7f6bcb5..413f69e 100644 --- a/scripts/test.cpp +++ b/scripts/test.cpp @@ -144,7 +144,7 @@ inline void expect_equality(char const *a, char const *b, std::size_t size) { * regions are tested. Uses a combination of deterministic and random tests with uniform and exponential distributions. */ static void test_memory_utilities(std::size_t experiments = 1024ull * 1024ull, - std::size_t max_l2_size = 1024ull * 1024ull * 32ull) { + std::size_t max_l2_size = 1024ull * 1024ull) { // We will be mirroring the operations on both standard and StringZilla strings. std::string text_stl(max_l2_size, '-');