Skip to content

Commit

Permalink
Add: Checksum kernels
Browse files Browse the repository at this point in the history
AVX-512, AVX2, NEON
  • Loading branch information
ashvardanian committed Dec 1, 2024
1 parent 98f857e commit a99337b
Show file tree
Hide file tree
Showing 3 changed files with 328 additions and 0 deletions.
7 changes: 7 additions & 0 deletions c/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ typedef struct sz_implementations_t {
sz_move_t move;
sz_fill_t fill;
sz_look_up_transform_t look_up_transform;
sz_checksum_t checksum;

sz_find_byte_t find_byte;
sz_find_byte_t rfind_byte;
Expand Down Expand Up @@ -155,6 +156,7 @@ static void sz_dispatch_table_init(void) {
impl->move = sz_move_serial;
impl->fill = sz_fill_serial;
impl->look_up_transform = sz_look_up_transform_serial;
impl->checksum = sz_checksum_serial;

impl->find = sz_find_serial;
impl->rfind = sz_rfind_serial;
Expand All @@ -176,6 +178,7 @@ static void sz_dispatch_table_init(void) {
impl->move = sz_move_avx2;
impl->fill = sz_fill_avx2;
impl->look_up_transform = sz_look_up_transform_avx2;
impl->checksum = sz_checksum_avx2;

impl->find_byte = sz_find_byte_avx2;
impl->rfind_byte = sz_rfind_byte_avx2;
Expand Down Expand Up @@ -209,6 +212,7 @@ static void sz_dispatch_table_init(void) {
impl->rfind_from_set = sz_rfind_charset_avx512;
impl->alignment_score = sz_alignment_score_avx512;
impl->look_up_transform = sz_look_up_transform_avx512;
impl->checksum = sz_checksum_avx512;
}
#endif

Expand All @@ -220,6 +224,7 @@ static void sz_dispatch_table_init(void) {
impl->move = sz_move_neon;
impl->fill = sz_fill_neon;
impl->look_up_transform = sz_look_up_transform_neon;
impl->checksum = sz_checksum_neon;

impl->find = sz_find_neon;
impl->rfind = sz_rfind_neon;
Expand Down Expand Up @@ -251,6 +256,8 @@ BOOL WINAPI DllMain(HINSTANCE hints, DWORD forward_reason, LPVOID lp) {
__attribute__((constructor)) static void sz_dispatch_table_init_on_gcc_or_clang(void) { sz_dispatch_table_init(); }
#endif

SZ_DYNAMIC sz_u64_t sz_checksum(sz_cptr_t text, sz_size_t length) { return sz_dispatch_table.checksum(text, length); }

SZ_DYNAMIC sz_bool_t sz_equal(sz_cptr_t a, sz_cptr_t b, sz_size_t length) {
return sz_dispatch_table.equal(a, b, length);
}
Expand Down
Loading

0 comments on commit a99337b

Please sign in to comment.