-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
84 lines (70 loc) · 3.31 KB
/
CMakeLists.txt
File metadata and controls
84 lines (70 loc) · 3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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.
cmake_minimum_required(VERSION 3.21)
project(svs_shared_library_example
LANGUAGES CXX
)
# Try to find SVS from system/conda/pip installation first
find_package(svs QUIET)
if(NOT svs_FOUND)
# If sourcing from pip/conda, the following steps are not necessary, simplifying workflow
# If not found, download tarball from GitHub release and follow steps to fetch and find
set(SVS_URL "https://github.com/intel/ScalableVectorSearch/releases/download/v0.3.0/svs-shared-library-0.3.0.tar.gz" CACHE STRINGS "URL to download SVS shared library tarball if not found in system")
message(STATUS "SVS not found in system, downloading from: ${SVS_URL}")
include(FetchContent)
FetchContent_Declare(
svs
URL "${SVS_URL}"
)
FetchContent_MakeAvailable(svs)
list(APPEND CMAKE_PREFIX_PATH "${svs_SOURCE_DIR}")
find_package(svs REQUIRED)
else()
message(STATUS "Found SVS: ${svs_DIR}")
endif()
set(SVS_CXX_STANDARD 20)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -DNDEBUG -std=gnu++20 -march=native -mtune=native -Werror -Wall -Wextra -Wpedantic" )
# Configure path to the datasets used in these examples
set(DATA_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../../data/test_dataset")
function(create_example_executable exe file)
add_executable(${exe} ${file})
target_compile_definitions(${exe} PRIVATE SVS_DATA_DIR="${DATA_DIRECTORY}")
target_link_libraries(${exe} PUBLIC
svs::svs_shared_library
svs::svs
)
endfunction()
create_example_executable(shared shared.cpp)
create_example_executable(example_vamana_with_compression_lvq example_vamana_with_compression_lvq.cpp)
create_example_executable(example_vamana_with_compression example_vamana_with_compression.cpp)
create_example_executable(example_vamana_with_compression_dynamic example_vamana_with_compression_dynamic.cpp)
# IVF examples with LVQ and LeanVec compression (only when IVF is enabled)
option(SVS_ENABLE_IVF_EXAMPLES "Build IVF examples" OFF)
if(SVS_ENABLE_IVF_EXAMPLES)
# Find MKL for IVF examples (required for cblas_sgemm)
set(MKL_THREADING sequential)
find_package(MKL REQUIRED)
function(create_ivf_example_executable exe file)
add_executable(${exe} ${file})
target_compile_definitions(${exe} PRIVATE SVS_DATA_DIR="${DATA_DIRECTORY}")
target_link_libraries(${exe} PUBLIC
svs::svs_shared_library
svs::svs
MKL::MKL
)
endfunction()
create_ivf_example_executable(example_ivf_with_compression_lvq example_ivf_with_compression_lvq.cpp)
create_ivf_example_executable(example_ivf_with_compression_leanvec example_ivf_with_compression_leanvec.cpp)
create_ivf_example_executable(example_ivf_with_compression_dynamic example_ivf_with_compression_dynamic.cpp)
endif()