Skip to content

Commit

Permalink
Fix: Explicit simsimd_size_t cast in SVE
Browse files Browse the repository at this point in the history
  • Loading branch information
ashvardanian committed Oct 12, 2024
1 parent 82146b0 commit 165986f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions include/stringzilla/stringzilla.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;

Expand All @@ -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);
}
}
Expand All @@ -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);
}
Expand All @@ -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;
Expand All @@ -6162,15 +6162,15 @@ 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;
source += body_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);
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, '-');
Expand Down

0 comments on commit 165986f

Please sign in to comment.