8000 refactor cmake by LHT129 · Pull Request #870 · antgroup/vsag · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

refactor cmake #870

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
8000
2 changes: 1 addition & 1 deletion .circleci/fresh_ci_cache.commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
39aebf3c03c5e26e8fb158b3ba54ba79a3f9513d
9f035bade6ddca04b17aff63de4a409f3d0f9de1
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ jobs:
save: ${{ github.event_name != 'pull_request' }}
key: build-lint-${{ hashFiles('./CMakeLists.txt') }}-${{ hashFiles('./.circleci/fresh_ci_cache.commit') }}
- name: Run lint
run: export CMAKE_GENERATOR="Ninja" && make debug && make lint
run: export CMAKE_GENERATOR="Ninja" && make release && make lint
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ cov: ## Build unit tests with code coverage enabled.

.PHONEY: lint
lint: ## Check coding styles defined in `.clang-tidy`.
@./scripts/linters/run-clang-tidy.py -p build/ -use-color -source-filter '^.*vsag\/src.*(?<!_test)\.cpp$$' -j ${COMPILE_JOBS}
@./scripts/linters/run-clang-tidy.py -p build-release/ -use-color -source-filter '^.*vsag\/src.*(?<!_test)\.cpp$$' -j ${COMPILE_JOBS}

.PHONEY: fix-lint
fix-lint: ## Fix coding style issues in-place via clang-apply-replacements, use it be careful!!!
@./scripts/linters/run-clang-tidy.py -p build/ -use-color -source-filter '^.*vsag\/src.*(?<!_test)\.cpp$$' -j ${COMPILE_JOBS} -fix
@./scripts/linters/run-clang-tidy.py -p build-release/ -use-color -source-filter '^.*vsag\/src.*(?<!_test)\.cpp$$' -j ${COMPILE_JOBS} -fix

.PHONY: test_parallel
test_parallel: ## Run all tests parallel (used in CI).
Expand Down
37 changes: 10 additions & 27 deletions src/CMakeLists.txt
10000
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,30 @@
add_subdirectory (simd)
add_subdirectory (io)
add_subdirectory (quantization)
add_subdirectory (impl/filter)
add_subdirectory (impl/transform)
add_subdirectory (impl)
add_subdirectory (storage)
add_subdirectory (attr)
add_subdirectory (data_cell)
add_subdirectory (algorithm)
add_subdirectory (utils)

file (GLOB CPP_SRCS "*.cpp")
list (FILTER CPP_SRCS EXCLUDE REGEX "_test.cpp")

file (GLOB CPP_ATTR_SRCS "attr/*.cpp")
file (GLOB CPP_ATTR_DETAIL_SRCS "attr/**/*.cpp")
list (APPEND CPP_ATTR_SRCS ${CPP_ATTR_DETAIL_SRCS})
list (FILTER CPP_ATTR_SRCS EXCLUDE REGEX "_test.cpp")

file (GLOB CPP_IMPL_SRCS "impl/*.cpp")
file (GLOB CPP_IMPL_EXTRA_SRCS "impl/bitset/*.cpp")
list (APPEND CPP_IMPL_SRCS ${CPP_IMPL_EXTRA_SRCS})
list (FILTER CPP_IMPL_SRCS EXCLUDE REGEX "_test.cpp")

file (GLOB CPP_INDEX_SRCS "index/*.cpp")
list (FILTER CPP_INDEX_SRCS EXCLUDE REGEX "_test.cpp")

file (GLOB CPP_DATA_CELL_SRCS "data_cell/*.cpp")
list (FILTER CPP_DATA_CELL_SRCS EXCLUDE REGEX "_test.cpp")

file (GLOB CPP_ALGORITHM_SRCS "algorithm/*.cpp")
file (GLOB CPP_ALGORITHM_EXTRA_SRCS "algorithm/**/*.cpp")
list (APPEND CPP_ALGORITHM_SRCS ${CPP_ALGORITHM_EXTRA_SRCS})
list (FILTER CPP_ALGORITHM_SRCS EXCLUDE REGEX "_test.cpp")

file (GLOB CPP_UTILS_SRCS "utils/*.cpp")
list (FILTER CPP_UTILS_SRCS EXCLUDE REGEX "_test.cpp")

set (VSAG_SRCS ${CPP_SRCS} ${CPP_ATTR_SRCS} ${CPP_INDEX_SRCS} ${CPP_IMPL_SRCS}
${CPP_DATA_CELL_SRCS} ${CPP_ALGORITHM_SRCS} ${CPP_UTILS_SRCS})
set (VSAG_SRCS ${CPP_SRCS} ${CPP_INDEX_SRCS})

add_library (vsag SHARED ${VSAG_SRCS})
add_library (vsag_static STATIC ${VSAG_SRCS})

set (VSAG_DEP_LIBS antlr4-autogen antlr4-runtime diskann simd io quantizer filter transform storage
pthread m dl fmt::fmt-header-only nlohmann_json::nlohmann_json roaring)
set (VSAG_DEP_LIBS antlr4-autogen antlr4-runtime diskann simd io quantizer storage utils
datacell ${IMPL_LIBS} ${ALGORITHM_LIBS} attr pthread m dl fmt::fmt nlohmann_json::nlohmann_json roaring)

target_link_libraries (vsag ${VSAG_DEP_LIBS} coverage_config)
target_link_libraries (vsag_static ${VSAG_DEP_LIBS} coverage_config)

add_dependencies (vsag spdlog)
add_dependencies (vsag_static spdlog)

Expand Down
16 changes: 16 additions & 0 deletions src/algorithm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

add_subdirectory (ivf_partition)
add_subdirectory (hnswlib)

file (GLOB ALGORITHM_SRCS "*.cpp")
list (FILTER ALGORITHM_SRCS EXCLUDE REGEX "_test.cpp")

add_library(algorithm OBJECT ${ALGORITHM_SRCS})
maybe_add_dependencies(algorithm spdlog fmt::fmt antlr4)


set (ALGORITHM_LIBS
algorithm
hnswlib
ivf_partition
PARENT_SCOPE)
6 changes: 3 additions & 3 deletions src/algorithm/brute_force.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
#include "brute_force.h"

#include "data_cell/flatten_datacell.h"
#include "impl/heap/standard_heap.h"
#include "inner_string_params.h"
#include "storage/serialization.h"
#include "utils/slow_task_timer.h"
#include "utils/standard_heap.h"
#include "utils/util_functions.h"

namespace vsag {
Expand Down Expand Up @@ -135,7 +135,7 @@ BruteForce::KnnSearch(const DatasetPtr& query,
}
}
auto [dataset_results, dists, ids] =
CreateFastDataset(static_cast<int64_t>(heap->Size()), allocator_);
create_fast_dataset(static_cast<int64_t>(heap->Size()), allocator_);
for (auto j = static_cast<int64_t>(heap->Size() - 1); j >= 0; --j) {
dists[j] = heap->Top().first;
ids[j] = this->label_table_->GetLabelById(heap->Top().second);
Expand Down Expand Up @@ -168,7 +168,7 @@ BruteForce::RangeSearch(const vsag::DatasetPtr& query,
}

auto [dataset_results, dists, ids] =
CreateFastDataset(static_cast<int64_t>(heap->Size()), allocator_);
create_fast_dataset(static_cast<int64_t>(heap->Size()), allocator_);
for (auto j = static_cast<int64_t>(heap->Size() - 1); j >= 0; --j) {
dists[j] = heap->Top().first;
ids[j] = this->label_table_->GetLabelById(heap->Top().second);
Expand Down
6 changes: 2 additions & 4 deletions src/algorithm/brute_force.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@

#include "algorithm/inner_index_interface.h"
#include "brute_force_parameter.h"
#include "common.h"
#include "data_cell/flatten_datacell.h"
#include "impl/filter/filter_headers.h"
#include "index_feature_list.h"
#include "data_cell/flatten_interface.h"
#include "label_table.h"
#include "typing.h"
#include "vsag/filter.h"

namespace vsag {

Expand Down
2 changes: 1 addition & 1 deletion src/algorithm/brute_force_parameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "brute_force_parameter.h"

#include <fmt/format-inl.h>
#include <fmt/format.h>

#include "vsag/constants.h"

Expand Down
10 changes: 5 additions & 5 deletions src/algorithm/hgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "hgraph.h"

#include <data_cell/compressed_graph_datacell_parameter.h>
#include <fmt/format-inl.h>
#include <fmt/format.h>

#include <memory>
#include <stdexcept>
Expand All @@ -25,6 +25,7 @@
#include "data_cell/graph_datacell_parameter.h"
#include "data_cell/sparse_graph_datacell.h"
#include "dataset_impl.h"
#include "impl/heap/standard_heap.h"
#include "impl/odescent_graph_builder.h"
#include "impl/pruning_strategy.h"
#include "impl/reorder.h"
Expand All @@ -34,7 +35,6 @@
#include "storage/serialization.h"
#include "storage/stream_reader.h"
#include "typing.h"
#include "utils/standard_heap.h"
#include "utils/util_functions.h"
#include "vsag/options.h"

Expand Down Expand Up @@ -358,7 +358,7 @@ HGraph::KnnSearch(const DatasetPtr& query,
return DatasetImpl::MakeEmptyDataset();
}
auto count = static_cast<const int64_t>(search_result->Size());
auto [dataset_results, dists, ids] = CreateFastDataset(count, search_allocator);
auto [dataset_results, dists, ids] = create_fast_dataset(count, search_allocator);
char* extra_infos = nullptr;
if (extra_info_size_ > 0) {
extra_infos = (char*)search_allocator->Allocate(extra_info_size_ * search_result->Size());
Expand Down Expand Up @@ -473,7 +473,7 @@ HGraph::KnnSearch(const DatasetPtr& query,
return DatasetImpl::MakeEmptyDataset();
}
auto count = static_cast<const int64_t>(search_result->Size());
auto [dataset_results, dists, ids] = CreateFastDataset(count, search_allocator);
auto [dataset_results, dists, ids] = create_fast_dataset(count, search_allocator);
char* extra_infos = nullptr;
if (extra_info_size_ > 0) {
extra_infos = (char*)search_allocator->Allocate(extra_info_size_ * search_result->Size());
Expand Down Expand Up @@ -633,7 +633,7 @@ HGraph::RangeSearch(const DatasetPtr& query,
}

auto count = static_cast<const int64_t>(search_result->Size());
auto [dataset_results, dists, ids] = CreateFastDataset(count, allocator_);
auto [dataset_results, dists, ids] = create_fast_dataset(count, allocator_);
char* extra_infos = nullptr;
if (extra_info_size_ > 0) {
extra_infos = (char*)allocator_->Allocate(extra_info_size_ * search_result->Size());
Expand Down
3 changes: 2 additions & 1 deletion src/algorithm/hgraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@
#include "data_cell/sparse_graph_datacell_parameter.h"
#include "default_thread_pool.h"
#include "hgraph_parameter.h"
#include "impl/basic_optimizer.h"
#include "impl/basic_searcher.h"
#include "impl/heap/distance_heap.h"
#include "index/index_common_param.h"
#include "index/iterator_filter.h"
#include "index_feature_list.h"
#include "inner_index_interface.h"
#include "lock_strategy.h"
#include "typing.h"
#include "utils/distance_heap.h"
#include "utils/visited_list.h"
#include "vsag/index.h"
#include "vsag/index_features.h"
Expand Down
9 changes: 9 additions & 0 deletions src/algorithm/hnswlib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

set (HNSWLIB_SRCS
block_manager.cpp
algorithm_interface.cpp
hnswalg.cpp
)

add_library (hnswlib OBJECT ${HNSWLIB_SRCS})
add_dependencies (hnswlib spdlog fmt::fmt)
2 changes: 1 addition & 1 deletion src/algorithm/hnswlib/block_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <functional>
#include <mutex>

#include "../../default_allocator.h"
#include "impl/allocator/default_allocator.h"
#include "storage/stream_reader.h"
#include "storage/stream_writer.h"

Expand Down
2 changes: 1 addition & 1 deletion src/algorithm/hnswlib/hnswalg.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "block_manager.h"
#include "data_cell/flatten_interface.h"
#include "data_cell/graph_interface.h"
#include "default_allocator.h"
#include "impl/allocator/default_allocator.h"
#include "index/iterator_filter.h"
#include "prefetch.h"
#include "simd/simd.h"
Expand Down
2 changes: 1 addition & 1 deletion src/algorithm/hnswlib/hnswalg_static.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
#include <stdexcept>
#include <unordered_set>
//#include <Eigen/Dense>
#include "../../default_allocator.h"
#include "hnswlib.h"
#include "impl/allocator/default_allocator.h"
#include "storage/stream_reader.h"
#include "visited_list_pool.h"

Expand Down
2 changes: 1 addition & 1 deletion src/algorithm/hnswlib/visited_list_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <iostream>
#include <mutex>

#include "../../default_allocator.h"
#include "impl/allocator/default_allocator.h"
#include "storage/stream_writer.h"
namespace vsag {

Expand Down
2 changes: 1 addition & 1 deletion src/algorithm/inner_index_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "inner_index_interface.h"

#include <fmt/format-inl.h>
#include <fmt/format.h>

#include "brute_force.h"
#include "empty_index_binary_set.h"
Expand Down
2 changes: 1 addition & 1 deletion src/algorithm/inner_index_interface_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "brute_force.h"
#include "hgraph.h"
#include "safe_allocator.h"
#include "impl/allocator/safe_allocator.h"

using namespace vsag;

Expand Down
10 changes: 5 additions & 5 deletions src/algorithm/ivf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "attr/executor/executor.h"
#include "attr/expression_visitor.h"
#include "impl/basic_searcher.h"
#include "impl/heap/standard_heap.h"
#include "impl/reorder.h"
#include "index/index_impl.h"
#include "inner_string_params.h"
Expand All @@ -29,7 +30,6 @@
#include "storage/serialization.h"
#include "storage/stream_reader.h"
#include "storage/stream_writer.h"
#include "utils/standard_heap.h"
#include "utils/util_functions.h"

namespace vsag {
Expand Down Expand Up @@ -362,7 +362,7 @@ IVF::KnnSearch(const DatasetPtr& query,
return reorder(k, search_result, query->GetFloat32Vectors());
}
auto count = static_cast<const int64_t>(search_result->Size());
auto [dataset_results, dists, labels] = CreateFastDataset(count, allocator_);
auto [dataset_results, dists, labels] = create_fast_dataset(count, allocator_);
for (int64_t j = count - 1; j >= 0; --j) {
dists[j] = search_result->Top().first;
labels[j] = label_table_->GetLabelById(search_result->Top().second);
Expand Down Expand Up @@ -391,7 +391,7 @@ IVF::RangeSearch(const DatasetPtr& query,
return reorder(k, search_result, query->GetFloat32Vectors());
}
auto count = static_cast<const int64_t>(search_result->Size());
auto [dataset_results, dists, labels] = CreateFastDataset(count, allocator_);
auto [dataset_results, dists, labels] = create_fast_dataset(count, allocator_);
for (int64_t j = count - 1; j >= 0; --j) {
dists[j] = search_result->Top().first;
labels[j] = label_table_->GetLabelById(search_result->Top().second);
Expand Down Expand Up @@ -550,7 +550,7 @@ IVF::create_search_param(const std::string& parameters, const FilterPtr& filter)

DatasetPtr
IVF::reorder(int64_t topk, DistHeapPtr& input, const float* query) const {
auto [dataset_results, dists, labels] = CreateFastDataset(topk, allocator_);
auto [dataset_results, dists, labels] = create_fast_dataset(topk, allocator_);
auto reorder_heap = Reorder::ReorderByFlatten(input, reorder_codes_, query, allocator_, topk);
for (int64_t j = topk - 1; j >= 0; --j) {
dists[j] = reorder_heap->Top().first;
Expand Down Expand Up @@ -772,7 +772,7 @@ IVF::SearchWithRequest(const SearchRequest& request) const {
return reorder(request.topk_, search_result, query->GetFloat32Vectors());
}
auto count = static_cast<const int64_t>(search_result->Size());
auto [dataset_results, dists, labels] = CreateFastDataset(count, allocator_);
auto [dataset_results, dists, labels] = create_fast_dataset(count, allocator_);
for (int64_t j = count - 1; j >= 0; --j) {
dists[j] = search_result->Top().first;
labels[j] = label_table_->GetLabelById(search_result->Top().second);
Expand Down
2 changes: 1 addition & 1 deletion src/algorithm/ivf.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
#include "data_cell/bucket_datacell.h"
#include "data_cell/flatten_interface.h"
#include "impl/basic_searcher.h"
#include "impl/heap/distance_heap.h"
#include "index/index_common_param.h"
#include "inner_index_interface.h"
#include "ivf_parameter.h"
#include "ivf_partition/ivf_partition_strategy.h"
#include "storage/stream_reader.h"
#include "storage/stream_writer.h"
#include "typing.h"
#include "utils/distance_heap.h"
#include "vsag/index.h"

namespace vsag {
Expand Down
2 changes: 1 addition & 1 deletion src/algorithm/ivf_parameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "ivf_parameter.h"

#include <fmt/format-inl.h>
#include <fmt/format.h>

#include "inner_string_params.h"
#include "vsag/constants.h"
Expand Down
11 changes: 11 additions & 0 deletions src/algorithm/ivf_partition/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

set (IVF_PARTITION_SRCS
gno_imi_parameter.cpp
ivf_nearest_partition.cpp
gno_imi_partition.cpp
ivf_partition_strategy_parameter.cpp
ivf_partition_strategy.cpp
)

add_library (ivf_partition OBJECT ${IVF_PARTITION_SRCS})
maybe_add_dependencies (ivf_partition spdlog fmt::fmt mkl openblas)
2 changes: 1 addition & 1 deletion src/algorithm/ivf_partition/gno_imi_parameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "gno_imi_parameter.h"

#include <fmt/format-inl.h>
#include <fmt/format.h>

#include <iostream>

Expand Down
Loading
Loading
0