-
Notifications
You must be signed in to change notification settings - Fork 965
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
101 lines (92 loc) · 3.61 KB
/
Copy pathCMakeLists.txt
File metadata and controls
101 lines (92 loc) · 3.61 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
include(${PROJECT_ROOT_DIR}/cmake/bazel.cmake)
include(${PROJECT_ROOT_DIR}/cmake/option.cmake)
if(RABITQ_SUPPORTED AND AUTO_DETECT_ARCH)
set(HNSW_RABITQ_FILES
hnsw_rabitq_query_algorithm.cc
hnsw_rabitq_streamer.cc
hnsw_rabitq_searcher.cc
hnsw_rabitq_entity.cc
rabitq_reformer.cc
rabitq_converter.cc
)
set(HNSW_RABITQ_FILES_FULL ${HNSW_RABITQ_FILES})
list(TRANSFORM HNSW_RABITQ_FILES_FULL PREPEND "algorithm/hnsw_rabitq/")
foreach(FILE ${HNSW_RABITQ_FILES_FULL})
set_source_files_properties(
${FILE}
PROPERTIES
COMPILE_FLAGS "${RABITQ_ARCH_FLAG}"
)
endforeach()
endif()
# utility/block_heap.cc uses AVX2 intrinsics guarded by __AVX2__. When the
# host toolchain supports it, compile this source with an AVX2-capable
# -march so AVX2 codegen is emitted. zvec_core glob-collects this source
# too, so per-file flags must be set here as well (in addition to the
# core_utility target in utility/CMakeLists.txt). Callers runtime-gate
# invocation of BlockHeap paths on CpuFeatures::AVX2.
if(NOT ANDROID AND AUTO_DETECT_ARCH)
if(HOST_ARCH MATCHES "^(x86|x64)$")
setup_compiler_march_for_x86(
_BLOCK_HEAP_MARCH_SSE _BLOCK_HEAP_MARCH_AVX2
_BLOCK_HEAP_MARCH_AVX512 _BLOCK_HEAP_MARCH_AVX512FP16)
if(_BLOCK_HEAP_MARCH_AVX2)
set_source_files_properties(
utility/block_heap.cc
PROPERTIES
COMPILE_FLAGS "${_BLOCK_HEAP_MARCH_AVX2}"
)
endif()
endif()
endif()
cc_directory(framework)
cc_directory(algorithm)
cc_directory(metric)
cc_directory(quantizer)
cc_directory(utility)
cc_directory(interface)
cc_directory(mixed_reducer)
git_version(GIT_SRCS_VER ${CMAKE_CURRENT_SOURCE_DIR})
file(GLOB_RECURSE ALL_CORE_SRCS *.cc *.c *.h)
# Remove algorithm/hnsw_rabitq implementation files if not supported.
# interface/indexes/hnsw_rabitq_index.cc is kept because it provides the vtable
# for HNSWRabitqIndex and guards rabitqlib usage with #if RABITQ_SUPPORTED.
if(NOT RABITQ_SUPPORTED)
list(FILTER ALL_CORE_SRCS EXCLUDE REGEX ".*/algorithm/hnsw_rabitq/.*")
endif()
# Exclude algorithm/diskann implementation files from zvec_core when not
# supported. Keep interface/indexes/diskann_index.cc in the core library so
# unsupported platforms still provide DiskAnnIndex's vtable and return
# IndexError_Unsupported from its guarded stubs.
#
# When DISKANN_SUPPORTED, the diskann sources are packed into zvec_core
# directly, so libzvec_core.so includes diskann symbols without needing a
# separate whole-archive step.
# The standalone core_knn_diskann library (built by algorithm/diskann) is still
# whole-archived into _zvec.so; since _zvec.so links zvec_core *normally*
# (not --whole-archive), the linker skips zvec_core's diskann objects there
# (symbols already resolved by core_knn_diskann_static) — no duplicates.
if(NOT DISKANN_SUPPORTED)
list(FILTER ALL_CORE_SRCS EXCLUDE REGEX ".*/algorithm/diskann/.*")
endif()
set(ZVEC_CORE_LIBS zvec_ailego zvec_turbo sparsehash magic_enum rabitqlib)
# The DiskAnn runtime loader uses dlopen/dlsym, so link libdl on Linux.
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
list(APPEND ZVEC_CORE_LIBS ${CMAKE_DL_LIBS})
endif()
set(ZVEC_CORE_LIBRARY_OPTIONS)
if(WIN32 AND (BUILD_ZVEC_CORE_SHARED OR BUILD_ZVEC_SHARED))
list(APPEND ZVEC_CORE_LIBRARY_OPTIONS OBJECTS)
if(BUILD_ZVEC_CORE_SHARED)
list(APPEND ZVEC_CORE_LIBRARY_OPTIONS
EXPORT_DEF ZVEC_CORE_BUILD_SHARED
)
endif()
endif()
cc_library(
NAME zvec_core STATIC STRICT PACKED ${ZVEC_CORE_LIBRARY_OPTIONS}
SRCS ${ALL_CORE_SRCS}
LIBS ${ZVEC_CORE_LIBS}
INCS . ${PROJECT_ROOT_DIR}/src/core
VERSION "${GIT_SRCS_VER}"
)