Skip to content

Commit

Permalink
Merge pull request #480 from unum-cloud/main-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ashvardanian authored Oct 10, 2024
2 parents b3da759 + 04eb837 commit 4c055d3
Show file tree
Hide file tree
Showing 34 changed files with 706 additions and 340 deletions.
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

0 comments on commit 4c055d3

Please sign in to comment.