Skip to content

Commit

Permalink
Make: Refresh compilers for pre-release tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ashvardanian committed Oct 2, 2023
1 parent 1218966 commit 229b805
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 42 deletions.
57 changes: 40 additions & 17 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,58 @@ permissions:

jobs:

test_cpp_c_ubuntu:
name: Test C++ Ubuntu (${{ matrix.compiler }})
test_cpp_c_ubuntu_gcc:
name: Test C++ Ubuntu (GCC)
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
compiler: [g++-9, g++-10, g++-11, clang-10, clang-11, clang-12]


steps:
- uses: actions/checkout@v3
with:
ref: main-dev
- run: git submodule update --init --recursive

- name: Install Dependencies
run: sudo apt update && sudo apt install -y cmake build-essential libjemalloc-dev libomp-dev g++-12

- name: Build
run: |
sudo apt update &&
sudo apt install -y cmake build-essential libjemalloc-dev ${{ matrix.compiler }}
export CC=gcc-12
export CXX=g++-12
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DUSEARCH_BUILD_TEST_CPP=1 -DUSEARCH_BUILD_TEST_C=1 -DUSEARCH_USE_OPENMP=1 -DUSEARCH_USE_SIMSIMD=1 -DUSEARCH_USE_JEMALLOC=1
cmake --build build --config Debug
- name: Run C++ tests
run: ./build/test_cpp
- name: Run C tests
run: ./build/test_c


test_cpp_c_ubuntu_clang:
name: Test C++ Ubuntu (Clang)
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
ref: main-dev
- run: git submodule update --init --recursive

- name: Install Dependencies
run: sudo apt update && sudo apt install -y cmake build-essential libjemalloc-dev clang-15

- name: Build
run: |
export CXX=${{ matrix.compiler }}
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DUSEARCH_BUILD_TEST=1 -DUSEARCH_BUILD_CTEST=1 -DUSEARCH_USE_OPENMP=1 -DUSEARCH_USE_SIMSIMD=1 -DUSEARCH_USE_JEMALLOC=1
export CC=clang-15
export CXX=clang++-15
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DUSEARCH_BUILD_TEST_CPP=1 -DUSEARCH_BUILD_TEST_C=1 -DUSEARCH_USE_SIMSIMD=1 -DUSEARCH_USE_JEMALLOC=1
cmake --build build --config Debug
- name: Run C++ tests
run: ./build/test_cpp
- name: Run C tests
run: ./build/test_c


test_cpp_c_macos:
name: Test C++ MacOS
runs-on: macos-latest
Expand All @@ -59,13 +82,13 @@ jobs:
run: |
brew update
brew install cmake
- name: Build
run: |
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DUSEARCH_BUILD_TEST=1 -DUSEARCH_BUILD_CTEST=1
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DUSEARCH_BUILD_TEST_CPP=1 -DUSEARCH_BUILD_TEST_C=1
cmake --build build --config Debug
- name: Run C++ tests
run: ./build/test
run: ./build/test_cpp
- name: Run C tests
run: ./build/test_c

Expand All @@ -83,12 +106,12 @@ jobs:

- name: Build
run: |
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DUSEARCH_BUILD_TEST=1 -DUSEARCH_BUILD_CTEST=1
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DUSEARCH_BUILD_TEST_CPP=1 -DUSEARCH_BUILD_TEST_C=1
cmake --build build --config Debug
- name: Run C++ tests
run: ./build/test
run: .\build\test_cpp
- name: Run C tests
run: ./build/test_c
run: .\build\test_c

test_python_311:
name: Test Python
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
"downcasted",
"Downcasting",
"dtype",
"DUSEARCH",
"emcmake",
"equi",
"equidimensional",
Expand Down
19 changes: 12 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ option(USEARCH_USE_SIMSIMD "Use SimSIMD hardware-accelerated metrics" OFF)
option(USEARCH_USE_JEMALLOC "Use JeMalloc for faster memory allocations" OFF)
option(USEARCH_USE_NATIVE_F16 "Use native half-precision types" OFF)

option(USEARCH_BUILD_TEST "Compile a native unit test in C++" ${USEARCH_IS_MAIN_PROJECT})
option(USEARCH_BUILD_BENCHMARK "Compile a native benchmark in C++" ${USEARCH_IS_MAIN_PROJECT})
option(USEARCH_BUILD_CLIB "Compile a native library for the C 99 interface" OFF)
option(USEARCH_BUILD_CTEST "Compile a test for the C 99 interface" OFF)
option(USEARCH_BUILD_TEST_CPP "Compile a native unit test in C++" ${USEARCH_IS_MAIN_PROJECT})
option(USEARCH_BUILD_BENCH_CPP "Compile a native benchmark in C++" ${USEARCH_IS_MAIN_PROJECT})
option(USEARCH_BUILD_LIB_C "Compile a native library for the C 99 interface" OFF)
option(USEARCH_BUILD_TEST_C "Compile a test for the C 99 interface" OFF)
option(USEARCH_BUILD_WOLFRAM "Compile Wolfram Language bindings" OFF)

# Includes
Expand Down Expand Up @@ -220,7 +220,10 @@ function (setup_target TARGET_NAME)
)

# Check if the compiler is AppleClang, and if not, add the leak sanitizer
if (NOT CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "AppleClang")
if (CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin")
# It's likely AppleClang Adjust options as needed for AppleClang
else ()
# It's likely LLVM Clang
target_compile_options(${TARGET_NAME} PRIVATE $<$<CONFIG:DEBUG>:-fsanitize=leak>)
target_link_options(${TARGET_NAME} PRIVATE $<$<CONFIG:DEBUG>:-fsanitize=leak>)
endif ()
Expand Down Expand Up @@ -255,6 +258,8 @@ function (setup_target TARGET_NAME)
endif ()

target_include_directories(${TARGET_NAME} PRIVATE ${USEARCH_HEADER_INCLUDES})
set_target_properties(${TARGET_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
set_target_properties(${TARGET_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
set_target_properties(${TARGET_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set_target_properties(${TARGET_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set_target_properties(${TARGET_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
Expand All @@ -272,7 +277,7 @@ function (setup_target TARGET_NAME)

endfunction ()

if (${USEARCH_BUILD_TEST} OR ${USEARCH_BUILD_BENCHMARK})
if (${USEARCH_BUILD_TEST_CPP} OR ${USEARCH_BUILD_BENCH_CPP})
add_subdirectory(cpp)
endif ()

Expand All @@ -284,6 +289,6 @@ if (${USEARCH_BUILD_WASM})
add_subdirectory(wasm)
endif ()

if (${USEARCH_BUILD_CLIB} OR ${USEARCH_BUILD_CTEST})
if (${USEARCH_BUILD_LIB_C} OR ${USEARCH_BUILD_TEST_C})
add_subdirectory(c)
endif ()
4 changes: 2 additions & 2 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"-fexceptions",
"-Wno-unknown-pragmas",
"-Wno-maybe-uninitialized",
"-std=c++11",
"-std=c++17",
],
"xcode_settings": {
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
Expand All @@ -30,7 +30,7 @@
"msvs_settings": {
"VCCLCompilerTool": {
"ExceptionHandling": 1,
"AdditionalOptions": ["-std:c++11"],
"AdditionalOptions": ["-std:c++17"],
}
},
}
Expand Down
4 changes: 2 additions & 2 deletions c/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if (USEARCH_BUILD_CLIB)
if (USEARCH_BUILD_TEST_C)
add_executable(test_c test.c lib.cpp)
setup_target(test_c)
include(CTest)
Expand All @@ -8,7 +8,7 @@ endif ()

# This article discusses a better way to allow building either static or shared libraries:
# https://alexreinking.com/blog/building-a-dual-shared-and-static-library-with-cmake.html
if (USEARCH_BUILD_CTEST)
if (USEARCH_BUILD_LIB_C)
add_library(usearch_c SHARED lib.cpp)
add_library(usearch_static_c STATIC lib.cpp)

Expand Down
6 changes: 2 additions & 4 deletions c/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
## Installation

The simplest form to integrate is to copy the contents of `usearch/c/` into your project.
To build the library `libusearch_static_c` and `libusearch_c`, pass enable the `USEARCH_BUILD_CLIB` CMake option:
To build the library `libusearch_static_c` and `libusearch_c`, pass enable the `USEARCH_BUILD_LIB_C` CMake option:

```bash
cmake -DUSEARCH_BUILD_CLIB=1 -DUSEARCH_BUILD_CTEST=1 -DUSEARCH_BUILD_STATIC=0 -DUSEARCH_BUILD_TEST=0 -DUSEARCH_BUILD_BENCHMARK=0 ..
cmake -DUSEARCH_BUILD_LIB_C=1 -DUSEARCH_BUILD_TEST_C=1 -DUSEARCH_BUILD_TEST_CPP=0 -DUSEARCH_BUILD_BENCH_CPP=0 ..
```

You can choose between a static and dynamic library by setting `USEARCH_BUILD_STATIC`.

## Quickstart

```c
Expand Down
5 changes: 2 additions & 3 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@

if (USEARCH_BUILD_TEST)
if (USEARCH_BUILD_TEST_CPP)
add_executable(test_cpp test.cpp)
setup_target(test_cpp)
include(CTest)
enable_testing()
add_test(NAME test_cpp COMMAND test_cpp)
endif ()

if (USEARCH_BUILD_BENCHMARK)
if (USEARCH_BUILD_BENCH_CPP)
include(clipp)
add_executable(bench_cpp bench.cpp)
setup_target(bench_cpp)
Expand Down
14 changes: 7 additions & 7 deletions docs/compilation.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ cmake -B ./build_release \
-DUSEARCH_USE_OPENMP=1 \
-DUSEARCH_USE_SIMSIMD=1 \
-DUSEARCH_USE_JEMALLOC=1 \
-DUSEARCH_BUILD_TEST=1 \
-DUSEARCH_BUILD_BENCHMARK=1 \
-DUSEARCH_BUILD_CTEST=1 \
-DUSEARCH_BUILD_CLIB=1 \
-DUSEARCH_BUILD_TEST_CPP=1 \
-DUSEARCH_BUILD_BENCH_CPP=1 \
-DUSEARCH_BUILD_LIB_C=1 \
-DUSEARCH_BUILD_TEST_C=1 \
&& \
make -C ./build_release -j
```
Expand All @@ -36,8 +36,8 @@ cmake -B ./build_release \
-DCMAKE_CXX_COMPILER="/opt/homebrew/opt/llvm/bin/clang++" \
-DUSEARCH_USE_OPENMP=1 \
-DUSEARCH_USE_SIMSIMD=1 \
-DUSEARCH_BUILD_BENCHMARK=1 \
-DUSEARCH_BUILD_TEST=1 \
-DUSEARCH_BUILD_BENCH_CPP=1 \
-DUSEARCH_BUILD_TEST_CPP=1 \
&& \
make -C ./build_release -j
```
Expand Down Expand Up @@ -168,7 +168,7 @@ make USEARCH_USE_OPENMP=1 USEARCH_USE_SIMSIMD=1 -C ./c libusearch_c.so
Using CMake:

```sh
cmake -B ./build_release -DUSEARCH_BUILD_CLIB=1 && make -C ./build_release -j
cmake -B ./build_release -DUSEARCH_BUILD_LIB_C=1 && make -C ./build_release -j
```

Testing on MacOS and Linux:
Expand Down

0 comments on commit 229b805

Please sign in to comment.