ashvardanian / StringZilla

Up to 10x faster strings for C, C++, Python, Rust, and Swift, leveraging SWAR and SIMD on Arm Neon and x86 AVX2 & AVX-512-capable chips to accelerate search, sort, edit distances, alignment scores, etc 🦖
https://ashvardanian.com/posts/stringzilla/
Apache License 2.0
1.9k stars 63 forks source link

CMake targets for the C shared library #126

Open Tafnab opened 3 months ago

Tafnab commented 3 months ago

Since StringZilla depends upon AVX or AVX-512 (as the case may be), does it automatically fail-over if the processor it's running on doesn't have AVX-512?

For example, if I build on a machine with AVX-512 and run on one with AVX, will StringZilla just work, no problems?

ashvardanian commented 3 months ago

Yes, @Tafnab, that's the "Dynamic Dispatch" part. If you add c/lib.c to you build pipeline, it will include all the backends into the binary, and will then pick the best one available at run time. If you only use the headers, that won't work. We can probably improve the CMake to expose multiple targets (related to #85), but I am always afraid of refactoring CMake 😅

Tafnab commented 3 months ago

@ashvardanian: I'm really interested in using it only for C++. c/lib.c looks like C++ will like it also. So what you're saying is that, in my C++ program (main somewhere), I should include this file, as well as the headers.

ashvardanian commented 2 months ago

Yes @Tafnab, that would be the way to do it, until I merge #85 and #136 - which may take a few weeks - refactoring CMake is a nightmare 😭