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

Casts, Docs, & Dynamic Dispatch #480

Merged
merged 41 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
4425f92
Make: Drop deprecated CI
ashvardanian Aug 27, 2024
09508ed
Docs: Add Missing Python docstrings
ashvardanian Aug 28, 2024
fa9bd7e
Merge branch 'main-dev' of https://github.com/unum-cloud/usearch into…
ashvardanian Aug 29, 2024
c7f2b6d
Fix: Missing `f16_native_t` symbol
ashvardanian Aug 29, 2024
0ab569d
Improve: Support mutable matrix slices
ashvardanian Aug 29, 2024
c059ba3
Improve: Separate `casts_punned_t`
ashvardanian Aug 29, 2024
d77a74c
Improve: Dynamic Dispatch
ashvardanian Sep 2, 2024
b9d947e
Merge branch 'main-dev' of https://github.com/unum-cloud/usearch into…
ashvardanian Sep 2, 2024
722bc33
Make: Bump SimSIMD to 5.0.1
ashvardanian Sep 2, 2024
5f1f688
Docs: `search_result_t` docstrings
ashvardanian Sep 3, 2024
0f266f3
Merge branch 'main-dev' of https://github.com/unum-cloud/usearch into…
ashvardanian Sep 3, 2024
d5223f2
Make: Include `simsimd/c/lib.c`
ashvardanian Sep 3, 2024
64fc971
Make: Conditionally include SimSIMD source
ashvardanian Sep 3, 2024
6da60a6
Improve: Remove dead code
ashvardanian Sep 3, 2024
be873fc
Make: Override language in `setup.py`
ashvardanian Sep 3, 2024
3accc70
Docs: Cleaner build commands
ashvardanian Sep 7, 2024
6b6827b
Make: Bump SimSIMD to v5.1.1-preview
ashvardanian Sep 7, 2024
ad8656e
Make: Upgrade CI to Ubuntu 24 & MacOS 14
ashvardanian Sep 7, 2024
43864db
Improve: Use `assert.throws` in JS tests (#487)
abetomo Sep 9, 2024
4fbb56e
Docs: Member lookup in C++ (#489)
ucasfl Sep 10, 2024
7dca8c7
Improve: Rust `Index` concurrency issues (#492)
jbrummack Sep 16, 2024
240fe9c
Docs: Update Contribution Guide on JavaScript (#493)
abetomo Sep 17, 2024
b00b255
Fix: Bump SimSIMD to hide `#warning` from MSVC
ashvardanian Sep 19, 2024
13bb555
Fix: Compatibility with SimSIMD v5.4
ashvardanian Sep 19, 2024
37ccb42
Make: Ugly hack for MacOS builds
ashvardanian Sep 19, 2024
937f538
Fix: Propagate native type support to SimSIMD
ashvardanian Sep 19, 2024
510c637
Make: Override `CC` in CI env
ashvardanian Sep 19, 2024
b952649
Make: Bump SimSIMD
ashvardanian Sep 19, 2024
86a165c
Make: Log library dependencies
ashvardanian Sep 19, 2024
7b81f6c
Make: Override flags for any Clang compiler
ashvardanian Sep 19, 2024
e0f4cc3
Make: Update C# paths for Arm MacOS runs
ashvardanian Sep 19, 2024
1384eaa
Make: Override `CC` in CI
ashvardanian Sep 19, 2024
4a7ebb8
Make: Override `CC` in `cibuildwheel`
ashvardanian Sep 19, 2024
191d9bb
Fix: MSVC-pragma warnings (#497)
mbautin Sep 28, 2024
bd5e579
Make: Link to pre-compiled SimSIMD wheel
ashvardanian Oct 9, 2024
d87a65d
Merge branch 'main' into main-dev
ashvardanian Oct 9, 2024
0fc72a2
Fix: Linking to SimSIMD symbols
ashvardanian Oct 10, 2024
ca58134
Fix: Use `ctypes` for Windows & Linux
ashvardanian Oct 10, 2024
77d20c6
Fix: Avoid `RTLD_GLOBAL` on Windows
ashvardanian Oct 10, 2024
fb201aa
Improve: Start with `import usearch`
ashvardanian Oct 10, 2024
04eb837
Make: Disable SimSIMD on Windows
ashvardanian Oct 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
75 changes: 40 additions & 35 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ jobs:
dry-run: "true"

test_ubuntu_gcc:
name: Ubuntu (GCC 12)
runs-on: ubuntu-22.04
name: Ubuntu (GCC 14)
runs-on: ubuntu-24.04
env:
CC: gcc-12
CXX: g++-12
CC: gcc
CXX: g++

steps:
- uses: actions/checkout@v4
Expand All @@ -67,12 +67,12 @@ jobs:
run: |
sudo apt update
sudo apt install -y cmake build-essential libjemalloc-dev libomp-dev gcc-12 g++-12
cmake -B build_artifacts -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUSEARCH_BUILD_TEST_CPP=1 -DUSEARCH_BUILD_TEST_C=1 -DUSEARCH_BUILD_LIB_C=1 -DUSEARCH_BUILD_SQLITE=1 -DUSEARCH_USE_OPENMP=1 -DUSEARCH_USE_SIMSIMD=1 -DUSEARCH_USE_JEMALLOC=1
cmake -B build_artifacts -D CMAKE_BUILD_TYPE=RelWithDebInfo -D USEARCH_BUILD_TEST_CPP=1 -D USEARCH_BUILD_TEST_C=1 -D USEARCH_BUILD_LIB_C=1 -D USEARCH_BUILD_SQLITE=1 -D USEARCH_USE_OPENMP=1 -D USEARCH_USE_SIMSIMD=1 -D USEARCH_USE_JEMALLOC=1
cmake --build build_artifacts --config RelWithDebInfo
- name: Test C++
run: ./build_artifacts/test_cpp
run: build_artifacts/test_cpp
- name: Test C
run: ./build_artifacts/test_c
run: build_artifacts/test_c

# Python
- name: Set up Python ${{ env.PYTHON_VERSION }}
Expand Down Expand Up @@ -141,11 +141,11 @@ jobs:
working-directory: ${{ github.workspace }}/golang/

test_ubuntu_clang:
name: Ubuntu (Clang 16)
runs-on: ubuntu-22.04
name: Ubuntu (Clang 18)
runs-on: ubuntu-24.04
env:
CC: clang-16
CXX: clang++-16
CC: clang
CXX: clang++

steps:
- uses: actions/checkout@v4
Expand All @@ -156,16 +156,13 @@ jobs:
- name: Build C/C++
run: |
sudo apt update
sudo apt install -y cmake build-essential libjemalloc-dev
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 16
cmake -B build_artifacts -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUSEARCH_BUILD_TEST_CPP=1 -DUSEARCH_BUILD_TEST_C=1 -DUSEARCH_BUILD_LIB_C=1 -DUSEARCH_BUILD_SQLITE=1 -DUSEARCH_USE_OPENMP=0 -DUSEARCH_USE_SIMSIMD=1 -DUSEARCH_USE_JEMALLOC=1
sudo apt install -y cmake build-essential libjemalloc-dev clang
cmake -B build_artifacts -D CMAKE_BUILD_TYPE=RelWithDebInfo -D USEARCH_BUILD_TEST_CPP=1 -D USEARCH_BUILD_TEST_C=1 -D USEARCH_BUILD_LIB_C=1 -D USEARCH_BUILD_SQLITE=1 -D USEARCH_USE_OPENMP=0 -D USEARCH_USE_SIMSIMD=1 -D USEARCH_USE_JEMALLOC=1
cmake --build build_artifacts --config RelWithDebInfo
- name: Test C++
run: ./build_artifacts/test_cpp
run: build_artifacts/test_cpp
- name: Test C
run: ./build_artifacts/test_c
run: build_artifacts/test_c

# JavaScript
- name: Set up Node.js
Expand All @@ -190,6 +187,9 @@ jobs:
pip install pytest pytest-repeat numpy numba cppyy
pip install --upgrade git+https://github.com/Maratyszcza/PeachPy
python -m pip install .
env:
CXX: clang++
CC: clang++ # Override the default compiler
- name: Test Python
run: pytest

Expand All @@ -208,7 +208,7 @@ jobs:

test_macos:
name: MacOS
runs-on: macos-12
runs-on: macos-14

steps:
- uses: actions/checkout@v4
Expand All @@ -219,12 +219,12 @@ jobs:
run: |
brew update
brew install cmake
cmake -B build_artifacts -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUSEARCH_BUILD_TEST_CPP=1 -DUSEARCH_BUILD_TEST_C=1 -DUSEARCH_BUILD_LIB_C=1 -DUSEARCH_BUILD_SQLITE=1
cmake -B build_artifacts -D CMAKE_BUILD_TYPE=RelWithDebInfo -D USEARCH_BUILD_TEST_CPP=1 -D USEARCH_BUILD_TEST_C=1 -D USEARCH_BUILD_LIB_C=1 -D USEARCH_BUILD_SQLITE=1
cmake --build build_artifacts --config RelWithDebInfo
- name: Test C++
run: ./build_artifacts/test_cpp
run: build_artifacts/test_cpp
- name: Test C
run: ./build_artifacts/test_c
run: build_artifacts/test_c

# JavaScript
- name: Set up Node.js
Expand All @@ -248,6 +248,9 @@ jobs:
python -m pip install --upgrade pip
pip install pytest pytest-repeat numpy
python -m pip install .
env:
CXX: clang++
CC: clang++ # Override the default compiler
- name: Test Python
run: pytest

Expand All @@ -264,11 +267,13 @@ jobs:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Test .NET
run: |
mkdir -p "${{ github.workspace }}/csharp/lib/runtimes/osx-x64/native"
cp "${{ github.workspace }}/build_artifacts/libusearch_c.dylib" "${{ github.workspace }}/csharp/lib/runtimes/osx-x64/native"
mkdir -p "${{ github.workspace }}/csharp/lib/runtimes/osx-arm64/native"
cp "${{ github.workspace }}/build_artifacts/libusearch_c.dylib" "${{ github.workspace }}/csharp/lib/runtimes/osx-arm64/native"
dotnet test -c Debug --logger "console;verbosity=detailed" --filter "FullyQualifiedName!=Cloud.Unum.USearch.Tests.UsearchIndexTests.PersistAndRestore"
shell: bash
working-directory: ${{ github.workspace }}/csharp
env:
DYLD_PRINT_LIBRARIES: 1

test_windows:
name: Windows
Expand All @@ -281,7 +286,7 @@ jobs:
- name: Build C/C++
run: |
choco install cmake
cmake -B build_artifacts -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUSEARCH_BUILD_TEST_CPP=1 -DUSEARCH_BUILD_TEST_C=1 -DUSEARCH_BUILD_LIB_C=1 -DUSEARCH_BUILD_SQLITE=0
cmake -B build_artifacts -D CMAKE_BUILD_TYPE=RelWithDebInfo -D USEARCH_BUILD_TEST_CPP=1 -D USEARCH_BUILD_TEST_C=1 -D USEARCH_BUILD_LIB_C=1 -D USEARCH_BUILD_SQLITE=0
cmake --build build_artifacts --config RelWithDebInfo
- name: Test C++
run: .\build_artifacts\test_cpp.exe
Expand Down Expand Up @@ -398,16 +403,16 @@ jobs:
- name: Build C/C++
run: |
cmake -B build_artifacts \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
-DCMAKE_C_COMPILER_TARGET=${{ matrix.target }} \
-DCMAKE_CXX_COMPILER_TARGET=${{ matrix.target }} \
-DCMAKE_SYSTEM_NAME=Linux \
-DCMAKE_SYSTEM_PROCESSOR=${{ matrix.arch }} \
-DUSEARCH_BUILD_LIB_C=1 \
-DUSEARCH_BUILD_SQLITE=1 \
-DUSEARCH_BUILD_TEST_CPP=0 \
-DUSEARCH_BUILD_BENCH_CPP=0
-D CMAKE_BUILD_TYPE=RelWithDebInfo \
-D CMAKE_EXPORT_COMPILE_COMMANDS=1 \
-D CMAKE_C_COMPILER_TARGET=${{ matrix.target }} \
-D CMAKE_CXX_COMPILER_TARGET=${{ matrix.target }} \
-D CMAKE_SYSTEM_NAME=Linux \
-D CMAKE_SYSTEM_PROCESSOR=${{ matrix.arch }} \
-D USEARCH_BUILD_LIB_C=1 \
-D USEARCH_BUILD_SQLITE=1 \
-D USEARCH_BUILD_TEST_CPP=0 \
-D USEARCH_BUILD_BENCH_CPP=0

cmake --build build_artifacts --config RelWithDebInfo

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macOS-11, windows-2022]
os: [ubuntu-22.04, macOS-12, windows-2022]
steps:
- name: Check out refreshed version
uses: actions/checkout@v4
Expand Down Expand Up @@ -318,7 +318,7 @@ jobs:
zip -r usearch_wasm_macos_"$arch"_${{ steps.set_version.outputs.version }}.zip libusearch_c.dylib
mv usearch_wasm_macos_"$arch"_${{ steps.set_version.outputs.version }}.zip ../ && rm -rf libusearch_c.dylib
done
if: matrix.os == 'macOS-11'
if: matrix.os == 'macOS-12'

- name: Build library on Windows
run: |
Expand Down Expand Up @@ -710,7 +710,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-12, windows-2022]
os: [ubuntu-22.04, macos-14, windows-2022]
runs-on: ${{ matrix.os }}
defaults:
run:
Expand Down Expand Up @@ -743,8 +743,8 @@ jobs:
brew install cmake
cmake -B build_artifacts -DCMAKE_BUILD_TYPE=Release -DUSEARCH_BUILD_TEST_CPP=0 -DUSEARCH_BUILD_TEST_C=0 -DUSEARCH_BUILD_LIB_C=1 -DUSEARCH_USE_OPENMP=0 -DUSEARCH_USE_SIMSIMD=1 -DUSEARCH_USE_JEMALLOC=0
cmake --build build_artifacts --config Release
mkdir -p "${{ github.workspace }}/csharp/lib/runtimes/osx-x64/native"
cp "${{ github.workspace }}/build_artifacts/libusearch_c.dylib" "${{ github.workspace }}/csharp/lib/runtimes/osx-x64/native"
mkdir -p "${{ github.workspace }}/csharp/lib/runtimes/osx-arm64/native"
cp "${{ github.workspace }}/build_artifacts/libusearch_c.dylib" "${{ github.workspace }}/csharp/lib/runtimes/osx-arm64/native"

- name: Build C library for Windows
if: matrix.os == 'windows-2022'
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
"astype",
"autovec",
"Availible",
"BFLOAT",
"bidict",
"BLAS",
"Cdecl",
Expand Down Expand Up @@ -167,7 +168,9 @@
"MSVC",
"Napi",
"ndarray",
"NDCG",
"ndim",
"nlevels",
"Numba",
"numpy",
"objc",
Expand Down
71 changes: 71 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,63 @@ set(USEARCH_CMAKE_PROJECT_CONFIG_FILE "${USEARCH_CMAKE_CONFIG_DIR}/${PROJECT_NAM
set(USEARCH_CMAKE_PROJECT_TARGETS_FILE "${USEARCH_CMAKE_CONFIG_DIR}/${PROJECT_NAME}Targets.cmake")
set(USEARCH_PKGCONFIG_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/pkgconfig")

include(CheckCSourceCompiles)
# Check for `__fp16` support
check_c_source_compiles(
[=[
int
main(int argc, char *argv)
{
__fp16 a = 1.0;
__fp16 b = a + a;
return 0;
}
]=]
USEARCH_CAN_COMPILE_FP16
)

# Check for `_Float16` support
check_c_source_compiles(
[=[
int
main(int argc, char *argv)
{
_Float16 a = 1.0;
_Float16 b = a + a;
return 0;
}
]=]
USEARCH_CAN_COMPILE_FLOAT16
)

# Check for `__bf16` support
check_c_source_compiles(
[=[
int
main(int argc, char *argv)
{
__bf16 a = 1.0;
__bf16 b = a + a;
return 0;
}
]=]
USEARCH_CAN_COMPILE_BF16
)

# Check for `_Bfloat16` support
check_c_source_compiles(
[=[
int
main(int argc, char *argv)
{
_Bfloat16 a = 1.0;
_Bfloat16 b = a + a;
return 0;
}
]=]
USEARCH_CAN_COMPILE_BFLOAT16
)

# Define our header-only library
add_library(${USEARCH_TARGET_NAME} INTERFACE)
add_library(${PROJECT_NAME}::${USEARCH_TARGET_NAME} ALIAS ${USEARCH_TARGET_NAME})
Expand All @@ -74,6 +131,20 @@ target_compile_definitions(${USEARCH_TARGET_NAME} INTERFACE "USEARCH_USE_OPENMP=
target_compile_definitions(${USEARCH_TARGET_NAME} INTERFACE "USEARCH_USE_FP16LIB=$<BOOL:${USEARCH_USE_FP16LIB}>")
target_compile_definitions(${USEARCH_TARGET_NAME} INTERFACE "USEARCH_USE_SIMSIMD=$<BOOL:${USEARCH_USE_SIMSIMD}>")

# Define which types can be compiled
target_compile_definitions(
${USEARCH_TARGET_NAME} INTERFACE "USEARCH_CAN_COMPILE_FP16=$<BOOL:${USEARCH_CAN_COMPILE_FP16}>"
)
target_compile_definitions(
${USEARCH_TARGET_NAME} INTERFACE "USEARCH_CAN_COMPILE_FLOAT16=$<BOOL:${USEARCH_CAN_COMPILE_FLOAT16}>"
)
target_compile_definitions(
${USEARCH_TARGET_NAME} INTERFACE "USEARCH_CAN_COMPILE_BF16=$<BOOL:${USEARCH_CAN_COMPILE_BF16}>"
)
target_compile_definitions(
${USEARCH_TARGET_NAME} INTERFACE "USEARCH_CAN_COMPILE_BFLOAT16=$<BOOL:${USEARCH_CAN_COMPILE_BFLOAT16}>"
)

target_include_directories(
${USEARCH_TARGET_NAME} ${USEARCH_SYSTEM_INCLUDE} INTERFACE $<BUILD_INTERFACE:${USEARCH_INCLUDE_BUILD_DIR}>
$<INSTALL_INTERFACE:include>
Expand Down
Loading
Loading