Skip to content

Commit

Permalink
Fix: Missing _mm_cvtsi128_si64x in Clang
Browse files Browse the repository at this point in the history
  • Loading branch information
ashvardanian committed Dec 1, 2024
1 parent c2b997c commit c8c6c7c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions include/stringzilla/stringzilla.h
Original file line number Diff line number Diff line change
Expand Up @@ -4022,7 +4022,7 @@ SZ_PUBLIC sz_u64_t sz_checksum_avx2(sz_cptr_t text, sz_size_t length) {
__m128i low_xmm = _mm256_castsi256_si128(sums_vec.ymm);
__m128i high_xmm = _mm256_extracti128_si256(sums_vec.ymm, 1);
__m128i sums_xmm = _mm_add_epi64(low_xmm, high_xmm);
sz_u64_t low = (sz_u64_t)_mm_cvtsi128_si64x(sums_xmm);
sz_u64_t low = (sz_u64_t)_mm_cvtsi128_si64(sums_xmm);
sz_u64_t high = (sz_u64_t)_mm_extract_epi64(sums_xmm, 1);
sz_u64_t result = low + high;
if (length) result += sz_checksum_serial(text, length);
Expand Down Expand Up @@ -4073,7 +4073,7 @@ SZ_PUBLIC sz_u64_t sz_checksum_avx2(sz_cptr_t text, sz_size_t length) {
__m128i low_xmm = _mm256_castsi256_si128(sums_vec.ymm);
__m128i high_xmm = _mm256_extracti128_si256(sums_vec.ymm, 1);
__m128i sums_xmm = _mm_add_epi64(low_xmm, high_xmm);
sz_u64_t low = (sz_u64_t)_mm_cvtsi128_si64x(sums_xmm);
sz_u64_t low = (sz_u64_t)_mm_cvtsi128_si64(sums_xmm);
sz_u64_t high = (sz_u64_t)_mm_extract_epi64(sums_xmm, 1);
result += low + high;
return result;
Expand Down Expand Up @@ -5306,7 +5306,7 @@ SZ_PUBLIC sz_u64_t sz_checksum_avx512(sz_cptr_t text, sz_size_t length) {
__mmask16 mask = _sz_u16_mask_until(length);
text_vec.xmms[0] = _mm_maskz_loadu_epi8(mask, text);
sums_vec.xmms[0] = _mm_sad_epu8(text_vec.xmms[0], _mm_setzero_si128());
sz_u64_t low = (sz_u64_t)_mm_cvtsi128_si64x(sums_vec.xmms[0]);
sz_u64_t low = (sz_u64_t)_mm_cvtsi128_si64(sums_vec.xmms[0]);
sz_u64_t high = (sz_u64_t)_mm_extract_epi64(sums_vec.xmms[0], 1);
return low + high;
}
Expand All @@ -5318,7 +5318,7 @@ SZ_PUBLIC sz_u64_t sz_checksum_avx512(sz_cptr_t text, sz_size_t length) {
__m128i low_xmm = _mm256_castsi256_si128(sums_vec.ymms[0]);
__m128i high_xmm = _mm256_extracti128_si256(sums_vec.ymms[0], 1);
__m128i sums_xmm = _mm_add_epi64(low_xmm, high_xmm);
sz_u64_t low = (sz_u64_t)_mm_cvtsi128_si64x(sums_xmm);
sz_u64_t low = (sz_u64_t)_mm_cvtsi128_si64(sums_xmm);
sz_u64_t high = (sz_u64_t)_mm_extract_epi64(sums_xmm, 1);
return low + high;
}
Expand Down Expand Up @@ -6092,7 +6092,7 @@ SZ_PUBLIC sz_bool_t sz_equal_neon(sz_cptr_t a, sz_cptr_t b, sz_size_t length) {
return sz_true_k;
}

SZ_PUBLIC sz_u64_t sz_checksum_neon(sz_cptr_t const *text, size_t length) {
SZ_PUBLIC sz_u64_t sz_checksum_neon(sz_cptr_t text, sz_size_t length) {
uint64x2_t sum_vec = vdupq_n_u64(0);

// Process 16 bytes (128 bits) at a time
Expand Down
14 changes: 8 additions & 6 deletions scripts/bench_token.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*
* This file is the sibling of `bench_sort.cpp`, `bench_search.cpp` and `bench_similarity.cpp`.
*/
#include <numeric> // `std::accumulate`

#include <bench.hpp>
#include <test.hpp> // `random_string`

Expand Down Expand Up @@ -189,7 +191,7 @@ void bench(strings_type &&strings) {

void bench_on_input_data(int argc, char const **argv) {
dataset_t dataset = prepare_benchmark_environment(argc, argv);

#if 0
std::printf("Benchmarking on the entire dataset:\n");
bench_unary_functions(dataset.tokens, random_generation_functions(100));
bench_unary_functions(dataset.tokens, random_generation_functions(20));
Expand All @@ -211,14 +213,14 @@ void bench_on_input_data(int argc, char const **argv) {
bench_unary_functions<std::vector<std::string_view>>({dataset.text}, fingerprinting_functions(128, 4 * 1024));
bench_unary_functions<std::vector<std::string_view>>({dataset.text}, fingerprinting_functions(128, 64 * 1024));
bench_unary_functions<std::vector<std::string_view>>({dataset.text}, fingerprinting_functions(128, 1024 * 1024));

#endif
// Baseline benchmarks for real words, coming in all lengths
std::printf("Benchmarking on entire dataset:\n");
bench<std::vector<std::string_view>>({dataset.text});
std::printf("Benchmarking on real lines:\n");
bench(dataset.lines);
std::printf("Benchmarking on real words:\n");
bench(dataset.tokens);
std::printf("Benchmarking on real lines:\n");
bench(dataset.lines);
std::printf("Benchmarking on entire dataset:\n");
bench<std::vector<std::string_view>>({dataset.text});

// Run benchmarks on tokens of different length
for (std::size_t token_length : {1, 2, 3, 4, 5, 6, 7, 8, 16, 32}) {
Expand Down
2 changes: 0 additions & 2 deletions scripts/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1546,12 +1546,10 @@ int main(int argc, char const **argv) {
std::printf("- Uses NEON: %s \n", SZ_USE_ARM_NEON ? "yes" : "no");
std::printf("- Uses SVE: %s \n", SZ_USE_ARM_SVE ? "yes" : "no");

#if 0
// Basic utilities
test_arithmetical_utilities();
test_memory_utilities();
test_replacements();
#endif

// Compatibility with STL
#if SZ_DETECT_CPP_17 && __cpp_lib_string_view
Expand Down

0 comments on commit c8c6c7c

Please sign in to comment.