Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StringZilla 4.0! #201

Open
wants to merge 75 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
fe4449b
Improve: `#pragma region` dashes
ashvardanian Nov 30, 2024
585f7d5
Fix: `sz_look_up_transform_avx512` declaration
ashvardanian Nov 30, 2024
4fa591b
Merge branch 'main-dev' of https://github.com/ashvardanian/StringZill…
ashvardanian Dec 2, 2024
715ad10
Docs: Levenshtein tutorial in Jupyter
ashvardanian Dec 2, 2024
d3b423a
Improve: Levenshtein functions for unicode
ashvardanian Dec 7, 2024
1765f33
Add: Missing Rust interfaces
ashvardanian Dec 7, 2024
62ca6a0
Fix: Default Levenshtein upper bound
ashvardanian Dec 7, 2024
0ee549a
Make: Inline ASM for detecting CPU features on ARM
GoWind Dec 7, 2024
43471aa
Add: New Levenshtein distance kernels
ashvardanian Dec 7, 2024
d0678f8
Fix: Wrong env. variable names
ashvardanian Dec 7, 2024
7b44e87
Merge branch 'main-dev' of https://github.com/ashvardanian/StringZill…
ashvardanian Dec 7, 2024
ecb3775
Make: Split ./include/stringzilla/stringzilla.h to ./include/stringzi…
ashvardanian Dec 7, 2024
22e3d1e
Make: Split ./include/stringzilla/stringzilla.h to ./include/stringzi…
ashvardanian Dec 7, 2024
bd54745
Make: Split ./include/stringzilla/stringzilla.h to ./include/stringzi…
ashvardanian Dec 7, 2024
8cb0742
Make: Split ./include/stringzilla/stringzilla.h to ./include/stringzi…
ashvardanian Dec 7, 2024
9e577be
Make: Split ./include/stringzilla/stringzilla.h to ./include/stringzi…
ashvardanian Dec 7, 2024
14ba3bf
Make: Split ./include/stringzilla/stringzilla.h to ./include/stringzi…
ashvardanian Dec 7, 2024
b007ba5
Make: Split ./include/stringzilla/stringzilla.h to ./include/stringzi…
ashvardanian Dec 7, 2024
974ed78
Make: Split ./include/stringzilla/stringzilla.h to ./include/stringzi…
ashvardanian Dec 7, 2024
9e9f256
Make: Split ./include/stringzilla/stringzilla.h to ./include/stringzi…
ashvardanian Dec 7, 2024
08d0a20
Make: Split ./include/stringzilla/stringzilla.h to ./include/stringzi…
ashvardanian Dec 7, 2024
a6768af
Make: Split ./include/stringzilla/stringzilla.h to ./include/stringzi…
ashvardanian Dec 7, 2024
1f60e6d
Make: Split ./include/stringzilla/stringzilla.h to ./include/stringzi…
ashvardanian Dec 7, 2024
d74e5dc
Make: Split ./include/stringzilla/stringzilla.h to ./include/stringzi…
ashvardanian Dec 7, 2024
10d829e
Make: Split ./include/stringzilla/stringzilla.h to ./include/stringzi…
ashvardanian Dec 7, 2024
7fdc58f
Make: Split ./include/stringzilla/stringzilla.h to ./include/stringzi…
ashvardanian Dec 7, 2024
e23c35f
Make: Split ./include/stringzilla/stringzilla.h to ./include/stringzi…
ashvardanian Dec 7, 2024
3f9c248
Make: Split ./include/stringzilla/stringzilla.h to ./include/stringzi…
ashvardanian Dec 7, 2024
89c4681
Make: Split ./include/stringzilla/stringzilla.h to ./include/stringzi…
ashvardanian Dec 7, 2024
5d0d2da
Make: Split ./include/stringzilla/stringzilla.h to ./include/stringzi…
ashvardanian Dec 7, 2024
3464cb4
Make: Split ./include/stringzilla/stringzilla.h to ./include/stringzi…
ashvardanian Dec 7, 2024
085d2d3
Make: Split ./include/stringzilla/stringzilla.h to ./include/stringzi…
ashvardanian Dec 7, 2024
cbfe5c7
Make: Split ./include/stringzilla/stringzilla.h to ./include/stringzi…
ashvardanian Dec 7, 2024
9b1948b
Make: Split ./include/stringzilla/stringzilla.h to ./include/stringzi…
ashvardanian Dec 7, 2024
c357c3e
Make: Split ./include/stringzilla/stringzilla.h to ./include/stringzi…
ashvardanian Dec 7, 2024
66778d6
Make: Split ./include/stringzilla/stringzilla.h to ./include/stringzi…
ashvardanian Dec 7, 2024
45e57ee
Make: Split ./include/stringzilla/stringzilla.h to ./include/stringzi…
ashvardanian Dec 7, 2024
9e31800
Make: Split ./include/stringzilla/stringzilla.h to ./include/stringzi…
ashvardanian Dec 7, 2024
2f76521
Make: Split ./include/stringzilla/stringzilla.h to ./include/stringzi…
ashvardanian Dec 7, 2024
2a1fcd1
Fix: Filter `find.h` file
ashvardanian Dec 7, 2024
295d49a
Fix: Filter `memory.h` file
ashvardanian Dec 7, 2024
8b401bd
Fix: Filter `similarity.h` file
ashvardanian Dec 7, 2024
be4c63d
Fix: Filter `hash.h` file
ashvardanian Dec 7, 2024
86f53d9
Test: Add ASCII utilities tests exposing final character exclusion bug
alexbarev Dec 7, 2024
8b44d6a
Improve: Platform-specific equality checks
ashvardanian Dec 7, 2024
4a1f03c
Make: Separate builds for Skylake & Ice
ashvardanian Dec 7, 2024
5b55e19
Fix: Filter `small_string.h` file
ashvardanian Dec 7, 2024
1ba7982
Fix: Filter `sort.h` file
ashvardanian Dec 7, 2024
b835051
Fix: Filter `types.h` file
ashvardanian Dec 7, 2024
5f7ca59
Fix: Minor macro mismatches
ashvardanian Dec 7, 2024
41e5917
Fix: Partially filter `stringzilla.h` file
ashvardanian Dec 7, 2024
fc408fa
Make: Split ./include/stringzilla/find.h to ./include/stringzilla/com…
ashvardanian Dec 7, 2024
49e8d9d
Make: Split ./include/stringzilla/find.h to ./include/stringzilla/com…
ashvardanian Dec 7, 2024
ad2af78
Make: Split ./include/stringzilla/find.h to ./include/stringzilla/com…
ashvardanian Dec 7, 2024
fc9e5d6
Make: Split ./include/stringzilla/find.h to ./include/stringzilla/com…
ashvardanian Dec 7, 2024
6512f1d
Fix: Filter `compare.h` file
ashvardanian Dec 7, 2024
00f27f6
Fix: Haswell compilation flag
ashvardanian Dec 8, 2024
406bf0f
Fix: Symbols names & visibility
ashvardanian Dec 8, 2024
364e2ca
Make: Rename `stringzillite` to `stringzilla_bare`
ashvardanian Dec 8, 2024
6d61c21
Make: Detect Apple Universal builds
ashvardanian Dec 8, 2024
19c2ae9
Improve: C++ version macros naming
ashvardanian Dec 8, 2024
645539b
Fix: Overriding LibC in 32-bit Windows
ashvardanian Dec 8, 2024
660923e
Test: Correct edge cases in ASCII tests
alexbarev Dec 9, 2024
064829a
Improve: Ignore 40 commits in blame
ashvardanian Dec 9, 2024
e20d207
Fix: Correct `basic_charset` operator (#203)
alexbarev Dec 9, 2024
0b83569
Merge branch 'main-dev' of https://github.com/ashvardanian/StringZill…
ashvardanian Dec 9, 2024
864ee03
Fix: Initializing `basic_charset`
ashvardanian Dec 9, 2024
c99daf3
Docs: Formatting docstring
ashvardanian Dec 9, 2024
002e433
Fix: Include last char in `basic_charset()` #202
ashvardanian Dec 9, 2024
084d653
Fix: Linking `stderr`
ashvardanian Dec 10, 2024
48e0913
Fix: Skylake dispatch
ashvardanian Dec 10, 2024
749b0d8
Fix: Bounded Levenshtein returns
ashvardanian Dec 10, 2024
2007d49
Fix: `sz_u512_vec_t` members visibility
ashvardanian Dec 10, 2024
f3811d7
Make: Library namespaced aliases
ashvardanian Dec 10, 2024
bd7054e
Fix: Masks back to using `BZHI`
ashvardanian Dec 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
6512f1d129aeddc8601c9df7332c135038914b68
fc9e5d61e5fb1c5031f6f10920f6b50e2530de1e
ad2af78f8651870727c5b39e1fea2eff26d71d2f
49e8d9d240993bdf68715a9c87824a032752798d
fc408fa0a0f2d947c610568bd7a5c4a60ecca443
b835051c09a0ecfc420932de444f3c6839610764
1ba7982559111d4fc9b58caa7bc7aa1c6e64257c
5b55e19d1378c61da88309b30a38f9cf7c64bf79
be4c63d926c8628451726863e4d14dbd1ea374dd
8b401bd41e4bd9c29c8fad9a5b83d8232efa50c7
295d49a38d66b08075357ac829ad66d80b5edab0
2a1fcd113d217e3124f6501c38e93a318aca37f0
2f7652141bd8dc3c2c38ab34321567bfcdb91d93
9e3180019acffe5261f0a1713b4ea324dca79ea0
45e57eefd796841cbd14ee7f75ec42b42b5bde0c
66778d6b2b3aa0eed27e32fbdceef79b8c54eda5
c357c3ea756523d3bcc8d8f25068ad08aef5456d
9b1948b3771c21dd56954e5f43301ca8a0b8b1a9
cbfe5c7ac6371047eae88621b092297474d0b82a
085d2d3c8b99e0f90d320dd027040e554e410929
3464cb428ae9a8721ab82a8c4bff214aa9ce6254
5d0d2da422c7df96f9613ec843cd47c579a2edce
89c46810c2f9bfafa31f8592339f9a1b45dcc245
3f9c248fbf59add2246055462e8fc19dc9f1693b
e23c35ff2c2d4ccb752f4ffbf9b6f39a1677b532
7fdc58fd26e06c41052287d47a9c729c068a95ca
10d829efcb8ed4cfa5f2db4050f8403184484423
d74e5dca2e62eb0078cb2ebacc0dac2b8bb92d54
1f60e6d7c81f0e285e594eb63fee6119e05a3e69
a6768af38b40307fe66364403f141c285b3e164c
08d0a20d35d3b29a44b9c8a826d53435c3ef839c
9e9f2567d052d635722921a1d70ec63d69ec6669
974ed78822dc0b519dd61bc1c4dc18d59fe4ad15
b007ba571860e1d3737d1478c7f8d66ae1839e36
14ba3bf3c43408438a7de9ad57118c747c1347b1
9e577be71dcd2e20854bf55f08c54854b3e82989
8cb0742b2d1b31b61fac5272f17017953c6677e6
bd547453122e9f8565e5be15f137e7b0de37caca
22e3d1e34d62d68c1e89df7c8bdc201faa18a9de
ecb377541d0c706cf8997faff4f026b07e3f76f3
2 changes: 1 addition & 1 deletion .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ jobs:
# We can't run the produced builds, but we can make sure they exist
- name: Test artifacts presense
run: |
test -e build_artifacts/libstringzillite.so
test -e build_artifacts/libstringzilla_bare.so
test -e build_artifacts/libstringzilla_shared.so
test -e build_artifacts/stringzilla_test_cpp20

Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,15 @@ jobs:

cmake --build build_release --config Release

cp build_release/libstringzillite.so "stringzillite_linux_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}.so"
mkdir -p "stringzillite_linux_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}/DEBIAN"
touch "stringzillite_linux_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}/DEBIAN/control"
mkdir -p "stringzillite_linux_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}/usr/local/lib"
mkdir "stringzillite_linux_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}/usr/local/include"
cp include/stringzilla/stringzilla.h "stringzillite_linux_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}/usr/local/include/"
cp build_release/libstringzillite.so "stringzillite_linux_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}/usr/local/lib/"
echo -e "Package: stringzilla\nVersion: ${{ steps.set_version.outputs.version }}\nMaintainer: Ash Vardanian\nArchitecture: ${{ matrix.arch }}\nDescription: SIMD-accelerated string search, sort, hashes, fingerprints, & edit distances" > "stringzillite_linux_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}/DEBIAN/control"
dpkg-deb --build "stringzillite_linux_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}"
cp build_release/libstringzilla_bare.so "stringzilla_bare_linux_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}.so"
mkdir -p "stringzilla_bare_linux_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}/DEBIAN"
touch "stringzilla_bare_linux_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}/DEBIAN/control"
mkdir -p "stringzilla_bare_linux_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}/usr/local/lib"
mkdir "stringzilla_bare_linux_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}/usr/local/include"
cp include/stringzilla/stringzilla.h "stringzilla_bare_linux_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}/usr/local/include/"
cp build_release/libstringzilla_bare.so "stringzilla_bare_linux_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}/usr/local/lib/"
echo -e "Package: stringzilla\nVersion: ${{ steps.set_version.outputs.version }}\nMaintainer: Ash Vardanian\nArchitecture: ${{ matrix.arch }}\nDescription: SIMD-accelerated string search, sort, hashes, fingerprints, & edit distances" > "stringzilla_bare_linux_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}/DEBIAN/control"
dpkg-deb --build "stringzilla_bare_linux_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}"

- name: Upload library
uses: xresloader/upload-to-github-release@v1
Expand Down Expand Up @@ -314,14 +314,14 @@ jobs:
run: |
cmake -DCMAKE_BUILD_TYPE=Release -B build_release
cmake --build build_release --config Release
tar -cvf "stringzillite_windows_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}.tar" "build_release/stringzillite.dll" "./include/stringzilla/stringzilla.h"
tar -cvf "stringzilla_bare_windows_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}.tar" "build_release/stringzilla_bare.dll" "./include/stringzilla/stringzilla.h"

- name: Upload archive
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
file: "stringzillite_windows_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}.tar"
file: "stringzilla_bare_windows_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}.tar"
update_latest_release: true

create_macos_library:
Expand Down Expand Up @@ -349,7 +349,7 @@ jobs:
run: |
cmake -DCMAKE_BUILD_TYPE=Release -B build_release
cmake --build build_release --config Release
zip -r stringzillite_macos_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}.zip build_release/libstringzillite.dylib include/stringzilla/stringzilla.h
zip -r stringzilla_bare_macos_${{ matrix.arch }}_${{ steps.set_version.outputs.version }}.zip build_release/libstringzilla_bare.dylib include/stringzilla/stringzilla.h

- name: Upload archive
uses: xresloader/upload-to-github-release@v1
Expand Down
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"Baeza",
"basicsize",
"bigram",
"bigrams",
"bioinformaticians",
"bioinformatics",
"Bitap",
Expand All @@ -38,6 +39,7 @@
"cheminformatics",
"cibuildwheel",
"CONCAT",
"constexpr",
"copydoc",
"Corasick",
"cptr",
Expand All @@ -50,6 +52,7 @@
"getslice",
"Giancarlo",
"Gonnet",
"Haswell",
"Heikki",
"hexdigits",
"Hirschberg's",
Expand Down Expand Up @@ -80,6 +83,7 @@
"Merkle-Damgård",
"Mersenne",
"MODINIT",
"MSVC",
"napi",
"nargsf",
"ndim",
Expand All @@ -102,6 +106,7 @@
"readlines",
"releasebuffer",
"rfind",
"rfinds",
"richcompare",
"Ritchie",
"rmatcher",
Expand All @@ -111,11 +116,13 @@
"rsplits",
"rstrip",
"SIMD",
"Skylake",
"splitlines",
"ssize",
"startswith",
"STL",
"stringzilla",
"stringzilla_bare",
"Strs",
"strzl",
"substr",
Expand All @@ -129,6 +136,7 @@
"unpoison",
"usecases",
"Vardanian",
"VBMI",
"vectorcallfunc",
"Wagner",
"whitespaces",
Expand Down
114 changes: 75 additions & 39 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,37 @@
cmake_minimum_required(VERSION 3.1)
# StringZilla CMakeLists.txt
#
# This file defines several library build & installation targets:
#
# - stringzilla_header: A header-only library with the StringZilla C and C++ headers.
# - stringzilla_shared: A shared library with the StringZilla C and C++ headers and dynamic SIMD dispatch.
# - stringzilla_bare: A shared library with the StringZilla headers, but without linking the standard C library.
#
# Tests for different C++ standards:
#
# - stringzilla_test_cpp11: C++11 baseline support.
# - stringzilla_test_cpp14: C++14 support with `std::less<std::string>`-like function objects.
# - stringzilla_test_cpp17: C++17 support with `std::string_view` compatibility.
# - stringzilla_test_cpp20: C++20 support with `<=>` operator and more `constexpr` features.
#
# Tests for different SIMD architectures:
#
# - stringzilla_test_cpp20_serial: A test executable for serial execution.
# - stringzilla_test_cpp20_haswell: A test executable for AVX2.
# - stringzilla_test_cpp20_ice: A test executable for AVX-512.
# - stringzilla_test_cpp20_neon: A test executable for ARM Neon.
# - stringzilla_test_cpp20_sve: A test executable for ARM Scalable Vector Extension.
#
# Benchmarks:
#
# - stringzilla_bench_search: A benchmark for substring search operations.
# - stringzilla_bench_similarity: A benchmark for similarity operations.
# - stringzilla_bench_sort: A benchmark for sorting operations.
# - stringzilla_bench_token: A benchmark for comparators and hash functions.
# - stringzilla_bench_container: A benchmark for STL containers powered by StringZilla.
# - stringzilla_bench_memory: A benchmark for LibC-style low-level memory operations.
#
# For higher-level language bindings separate build scripts are provided, native to each toolchain.
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
project(
stringzilla
VERSION 3.11.0
Expand All @@ -7,7 +40,7 @@ project(
HOMEPAGE_URL "https://github.com/ashvardanian/stringzilla")

set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 17) # This gives many issues for msvc and clang-cl, especially if later on you set it to std-c++11 later on in the tests...
set(CMAKE_CXX_STANDARD 11)

set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_CXX_EXTENSIONS OFF)
Expand Down Expand Up @@ -46,7 +79,7 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|AARCH64|arm64|ARM64")
message(STATUS "Platform: ARM")
endif()

# Determine if StringZilla is built as a subproject (using `add_subdirectory`)
# Determine if StringZilla is built as a sub-project (using `add_subdirectory`)
# or if it is the main project
set(STRINGZILLA_IS_MAIN_PROJECT OFF)

Expand Down Expand Up @@ -78,19 +111,9 @@ endif()

# Configuration
include(GNUInstallDirs)
set(STRINGZILLA_TARGET_NAME ${PROJECT_NAME})
set(STRINGZILLA_INCLUDE_BUILD_DIR "${PROJECT_SOURCE_DIR}/include/")
set(STRINGZILLA_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}")

# Define our library
add_library(${STRINGZILLA_TARGET_NAME} INTERFACE)
add_library(${PROJECT_NAME}::${STRINGZILLA_TARGET_NAME} ALIAS ${STRINGZILLA_TARGET_NAME})

target_include_directories(
${STRINGZILLA_TARGET_NAME}
INTERFACE $<BUILD_INTERFACE:${STRINGZILLA_INCLUDE_BUILD_DIR}>
$<INSTALL_INTERFACE:include>)


if(${CMAKE_VERSION} VERSION_EQUAL 3.13 OR ${CMAKE_VERSION} VERSION_GREATER 3.13)
include(CTest)
Expand All @@ -99,7 +122,7 @@ endif()

if (MSVC)
# Remove /RTC* from MSVC debug flags by default (it will be added back in the set_compiler_flags function)
# Beacuse /RTC* cannot be used without the crt so it needs to be disabled for that specifc target
# Because /RTC* cannot be used without the crt so it needs to be disabled for that specific target
string(REGEX REPLACE "/RTC[^ ]*" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
string(REGEX REPLACE "/RTC[^ ]*" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
endif()
Expand All @@ -109,7 +132,6 @@ function(set_compiler_flags target cpp_standard target_arch)
get_target_property(target_type ${target} TYPE)

target_include_directories(${target} PRIVATE scripts)
target_link_libraries(${target} PRIVATE ${STRINGZILLA_TARGET_NAME})

# Set output directory for single-configuration generators (like Make)
set_target_properties(${target} PROPERTIES
Expand Down Expand Up @@ -245,6 +267,7 @@ endfunction()
function(define_launcher exec_name source cpp_standard target_arch)
add_executable(${exec_name} ${source})
set_compiler_flags(${exec_name} ${cpp_standard} "${target_arch}")
target_link_libraries(${exec_name} PRIVATE stringzilla_header)
add_test(NAME ${exec_name} COMMAND ${exec_name})
endfunction()

Expand All @@ -270,25 +293,36 @@ if(${STRINGZILLA_BUILD_TEST})
if(SZ_PLATFORM_X86)
# x86 specific backends
if (MSVC)
define_launcher(stringzilla_test_cpp20_x86_serial scripts/test.cpp 20 "AVX")
define_launcher(stringzilla_test_cpp20_x86_avx2 scripts/test.cpp 20 "AVX2")
define_launcher(stringzilla_test_cpp20_x86_avx512 scripts/test.cpp 20 "AVX512")
define_launcher(stringzilla_test_cpp20_serial scripts/test.cpp 20 "AVX")
define_launcher(stringzilla_test_cpp20_haswell scripts/test.cpp 20 "AVX2")
define_launcher(stringzilla_test_cpp20_ice scripts/test.cpp 20 "AVX512")
else()
define_launcher(stringzilla_test_cpp20_x86_serial scripts/test.cpp 20 "ivybridge")
define_launcher(stringzilla_test_cpp20_x86_avx2 scripts/test.cpp 20 "haswell")
define_launcher(stringzilla_test_cpp20_x86_avx512 scripts/test.cpp 20 "sapphirerapids")
define_launcher(stringzilla_test_cpp20_serial scripts/test.cpp 20 "ivybridge")
define_launcher(stringzilla_test_cpp20_haswell scripts/test.cpp 20 "haswell")
define_launcher(stringzilla_test_cpp20_ice scripts/test.cpp 20 "sapphirerapids")
endif()
elseif(SZ_PLATFORM_ARM)
# ARM specific backends
define_launcher(stringzilla_test_cpp20_arm_serial scripts/test.cpp 20 "armv8-a")
define_launcher(stringzilla_test_cpp20_arm_neon scripts/test.cpp 20 "armv8-a+simd")
define_launcher(stringzilla_test_cpp20_serial scripts/test.cpp 20 "armv8-a")
define_launcher(stringzilla_test_cpp20_neon scripts/test.cpp 20 "armv8-a+simd")
define_launcher(stringzilla_test_cpp20_sve scripts/test.cpp 20 "armv8.2-a+sve")
endif()
endif()

# Define our libraries, first the header-only version
add_library(stringzilla_header INTERFACE)
add_library(${PROJECT_NAME}::stringzilla_header ALIAS stringzilla_header)
target_include_directories(
stringzilla_header
INTERFACE $<BUILD_INTERFACE:${STRINGZILLA_INCLUDE_BUILD_DIR}>
$<INSTALL_INTERFACE:include>)


if(${STRINGZILLA_BUILD_SHARED})

function(define_shared target)
add_library(${target} SHARED c/lib.c)
add_library(${PROJECT_NAME}::${target} ALIAS ${target})

set_target_properties(${target} PROPERTIES
VERSION ${PROJECT_VERSION}
Expand All @@ -303,18 +337,20 @@ if(${STRINGZILLA_BUILD_SHARED})
endif()

target_compile_definitions(${target} PRIVATE
"SZ_USE_X86_AVX512=1"
"SZ_USE_X86_AVX2=1"
"SZ_USE_ARM_NEON=0"
"SZ_USE_ARM_SVE=0")
"SZ_USE_HASWELL=1"
"SZ_USE_SKYLAKE=1"
"SZ_USE_ICE=1"
"SZ_USE_NEON=0"
"SZ_USE_SVE=0")
elseif(SZ_PLATFORM_ARM)
set_compiler_flags(${target} "" "armv8-a")

target_compile_definitions(${target} PRIVATE
"SZ_USE_X86_AVX512=0"
"SZ_USE_X86_AVX2=0"
"SZ_USE_ARM_NEON=1"
"SZ_USE_ARM_SVE=1")
"SZ_USE_HASWELL=0"
"SZ_USE_SKYLAKE=0"
"SZ_USE_ICE=0"
"SZ_USE_NEON=1"
"SZ_USE_SVE=1")
endif()

if (MSVC)
Expand All @@ -333,16 +369,16 @@ if(${STRINGZILLA_BUILD_SHARED})
target_compile_definitions(stringzilla_shared PRIVATE "SZ_OVERRIDE_LIBC=1")

# Try compiling a version without linking the LibC
define_shared(stringzillite)
target_compile_definitions(stringzillite PRIVATE "SZ_AVOID_LIBC=1")
target_compile_definitions(stringzillite PRIVATE "SZ_OVERRIDE_LIBC=1")
define_shared(stringzilla_bare)
target_compile_definitions(stringzilla_bare PRIVATE "SZ_AVOID_LIBC=1")
target_compile_definitions(stringzilla_bare PRIVATE "SZ_OVERRIDE_LIBC=1")

# Avoid built-ins on MSVC and other compilers, as that will cause compileration errors
target_compile_options(stringzillite PRIVATE
# Avoid built-ins on MSVC and other compilers, as that will cause compilation errors
target_compile_options(stringzilla_bare PRIVATE
"$<$<CXX_COMPILER_ID:GNU,Clang>:-fno-builtin;-nostdlib>"
"$<$<CXX_COMPILER_ID:MSVC>:/Oi-;/GS->")
target_link_options(stringzillite PRIVATE "$<$<CXX_COMPILER_ID:GNU,Clang>:-nostdlib>")
target_link_options(stringzillite PRIVATE "$<$<CXX_COMPILER_ID:MSVC>:/NODEFAULTLIB>")
target_link_options(stringzilla_bare PRIVATE "$<$<CXX_COMPILER_ID:GNU,Clang>:-nostdlib>")
target_link_options(stringzilla_bare PRIVATE "$<$<CXX_COMPILER_ID:MSVC>:/NODEFAULTLIB>")


endif()
Expand All @@ -360,7 +396,7 @@ if(STRINGZILLA_INSTALL)
RESOURCE
RUNTIME)
install(
TARGETS stringzillite
TARGETS stringzilla_bare
ARCHIVE
BUNDLE
FRAMEWORK
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Replacing the default compiler is not recommended, as it may break the system, b

```bash
brew install llvm
cmake -D CMAKE_BUILD_TYPE=Release -D SIMSIMD_BUILD_TESTS=1 \
cmake -D CMAKE_BUILD_TYPE=Release -D STRINGZILLA_BUILD_TEST=1 \
-D CMAKE_C_COMPILER="$(brew --prefix llvm)/bin/clang" \
-D CMAKE_CXX_COMPILER="$(brew --prefix llvm)/bin/clang++" \
-B build_release
Expand All @@ -131,8 +131,8 @@ Using modern syntax, this is how you build and run the test suite:
cmake -D STRINGZILLA_BUILD_TEST=1 -D CMAKE_BUILD_TYPE=Debug -B build_debug
cmake --build build_debug --config Debug # Which will produce the following targets:
build_debug/stringzilla_test_cpp20 # Unit test for the entire library compiled for current hardware
build_debug/stringzilla_test_cpp20_x86_serial # x86 variant compiled for IvyBridge - last arch. before AVX2
build_debug/stringzilla_test_cpp20_arm_serial # Arm variant compiled without Neon
build_debug/stringzilla_test_cpp20_serial # x86 variant compiled for IvyBridge - last arch. before AVX2
build_debug/stringzilla_test_cpp20_serial # Arm variant compiled without Neon
```

To use CppCheck for static analysis make sure to export the compilation commands.
Expand Down
Loading
Loading