Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 6 additions & 1 deletion bindings/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ else()
set(SVS_LEANVEC_HEADER "svs/extensions/vamana/leanvec.h")
endif()

if ((SVS_RUNTIME_ENABLE_LVQ_LEANVEC))
if (SVS_RUNTIME_ENABLE_LVQ_LEANVEC)
if(RUNTIME_BINDINGS_PRIVATE_SOURCE_BUILD)
message(STATUS "Building directly from private sources")
target_link_libraries(${TARGET_NAME} PRIVATE
Expand Down Expand Up @@ -117,6 +117,7 @@ if ((SVS_RUNTIME_ENABLE_LVQ_LEANVEC))
FetchContent_Declare(
svs
URL ${SVS_URL}
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
)
FetchContent_MakeAvailable(svs)
list(APPEND CMAKE_PREFIX_PATH "${svs_SOURCE_DIR}")
Expand Down Expand Up @@ -192,3 +193,7 @@ install(FILES
DESTINATION "${SVS_RUNTIME_CONFIG_INSTALL_DIR}"
)

# Build tests if requested
if(SVS_BUILD_RUNTIME_TESTS)
add_subdirectory(tests)
endif()
9 changes: 8 additions & 1 deletion bindings/cpp/src/dynamic_vamana_index_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -450,12 +450,19 @@ class DynamicVamanaIndexImpl {
auto threadpool = default_threadpool();

svs::DistanceDispatcher distance_dispatcher(to_svs_distance(metric));

// Create allocator with custom block size for data loading
auto parameters =
svs::data::BlockingParameters{.blocksize_bytes = svs::lib::PowerOfTwo(26)};
auto allocator = svs::data::Blocked<svs::lib::Allocator<std::byte>>{parameters};

return distance_dispatcher([&](auto&& distance) {
return new svs::DynamicVamana(
svs::DynamicVamana::assemble<float, storage::StorageType_t<Tag>>(
stream,
std::forward<decltype(distance)>(distance),
std::move(threadpool)
std::move(threadpool),
allocator
)
);
});
Expand Down
84 changes: 84 additions & 0 deletions bindings/cpp/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Copyright 2025 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

include(FetchContent)

# Configure Catch2 for unit testing
# Do wide printing for the console logger for Catch2
# Reference: https://github.com/catchorg/Catch2/issues/1348
set(CATCH_CONFIG_CONSOLE_WIDTH "100" CACHE STRING "" FORCE)
set(CATCH_BUILD_TESTING OFF CACHE BOOL "" FORCE)
set(CATCH_CONFIG_ENABLE_BENCHMARKING OFF CACHE BOOL "" FORCE)
set(CATCH_CONFIG_FAST_COMPILE OFF CACHE BOOL "" FORCE)

# If we don't configure the prefix version of the Catch2 macros, then we get compiler
# errors about repeated definitions of the macro `INFO`
set(CATCH_CONFIG_PREFIX_ALL ON CACHE BOOL "" FORCE)

# Download the Catch2 unit testing suite.
# Reference: https://github.com/catchorg/Catch2/blob/devel/docs/cmake-integration.md
set(PRESET_CMAKE_CXX_STANDARD ${CMAKE_CXX_STANDARD})
set(CMAKE_CXX_STANDARD 20)
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.4.0
)

FetchContent_MakeAvailable(Catch2)
set(CMAKE_CXX_STANDARD ${PRESET_CMAKE_CXX_STANDARD})

# Add test executable
set(TEST_SOURCES
${CMAKE_CURRENT_LIST_DIR}/runtime_test.cpp
)

add_executable(svs_runtime_test ${TEST_SOURCES})

# Link with the runtime library
target_link_libraries(svs_runtime_test PRIVATE
svs_runtime
Catch2::Catch2WithMain
)

# Set C++ standard
target_compile_features(svs_runtime_test PRIVATE cxx_std_20)
set_target_properties(svs_runtime_test PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
)

# Include directories for test utilities
target_include_directories(svs_runtime_test PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../include
)

# Enable testing with CTest
include(CTest)
enable_testing()

# Add the test to CTest
add_test(NAME svs_runtime_test COMMAND svs_runtime_test)

# Set test properties
set_tests_properties(svs_runtime_test PROPERTIES
LABELS "runtime_bindings"
)

# Optional: Add Catch2's automatic test discovery
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
include(Catch)
catch_discover_tests(svs_runtime_test)
Loading
Loading