Skip to content

Commit

Permalink
Remove parallel_mode (milvus-io#1027)
Browse files Browse the repository at this point in the history
Signed-off-by: Yudong Cai <yudong.cai@zilliz.com>
  • Loading branch information
cydrain authored Aug 9, 2023
1 parent 9881230 commit 2de62cb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 16 deletions.
10 changes: 2 additions & 8 deletions src/index/ivf/ivf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -375,15 +375,10 @@ IvfIndexNode<T>::Search(const DataSet& dataset, const Config& cfg, const BitsetV
auto k = ivf_cfg.k.value();
auto nprobe = ivf_cfg.nprobe.value();

int parallel_mode = 0;
if (nprobe > 1 && rows <= 4) {
parallel_mode = 1;
}
int64_t* ids(new (std::nothrow) int64_t[rows * k]);
float* distances(new (std::nothrow) float[rows * k]);
int32_t* i_distances = reinterpret_cast<int32_t*>(distances);
try {
size_t max_codes = 0;
std::vector<folly::Future<folly::Unit>> futs;
futs.reserve(rows);
for (int i = 0; i < rows; ++i) {
Expand All @@ -401,11 +396,10 @@ IvfIndexNode<T>::Search(const DataSet& dataset, const Config& cfg, const BitsetV
} else if constexpr (std::is_same<T, faiss::IndexIVFFlat>::value) {
auto cur_data = (const float*)data + index * dim;
index_->search_without_codes_thread_safe(1, cur_data, k, distances + offset, ids + offset, nprobe,
parallel_mode, max_codes, bitset);
0, bitset);
} else {
auto cur_data = (const float*)data + index * dim;
index_->search_thread_safe(1, cur_data, k, distances + offset, ids + offset, nprobe, parallel_mode,
max_codes, bitset);
index_->search_thread_safe(1, cur_data, k, distances + offset, ids + offset, nprobe, 0, bitset);
}
}));
}
Expand Down
2 changes: 0 additions & 2 deletions thirdparty/faiss/faiss/IndexIVF.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ struct IndexIVF : Index, Level1Quantizer {
float* distances,
idx_t* labels,
const size_t nprobe,
const int parallel_mode,
const size_t max_codes,
const BitsetView bitset = nullptr) const;

Expand All @@ -283,7 +282,6 @@ struct IndexIVF : Index, Level1Quantizer {
float* distances,
idx_t* labels,
const size_t nprobe,
const int parallel_mode,
const size_t max_codes,
const BitsetView bitset = nullptr) const;

Expand Down
8 changes: 2 additions & 6 deletions thirdparty/faiss/faiss/IndexIVFThreadSafe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,12 @@ void IndexIVF::search_thread_safe(
float* distances,
idx_t* labels,
const size_t nprobe,
const int parallel_mode,
const size_t max_codes,
const BitsetView bitset) const {
FAISS_THROW_IF_NOT(k > 0);
const size_t final_nprobe = std::min(nlist, nprobe);
FAISS_THROW_IF_NOT(final_nprobe > 0);
IVFSearchParameters params =
gen_search_param(final_nprobe, parallel_mode, max_codes);
IVFSearchParameters params = gen_search_param(final_nprobe, 0, max_codes);

// search function for a subset of queries
auto sub_search_func = [this, k, final_nprobe, bitset, &params](
Expand Down Expand Up @@ -132,14 +130,12 @@ void IndexIVF::search_without_codes_thread_safe(
float* distances,
idx_t* labels,
const size_t nprobe,
const int parallel_mode,
const size_t max_codes,
const BitsetView bitset) const {
FAISS_THROW_IF_NOT(k > 0);
const size_t final_nprobe = std::min(nlist, nprobe);
FAISS_THROW_IF_NOT(final_nprobe > 0);
IVFSearchParameters params =
gen_search_param(final_nprobe, parallel_mode, max_codes);
IVFSearchParameters params = gen_search_param(final_nprobe, 0, max_codes);

// search function for a subset of queries
auto sub_search_func = [this, k, final_nprobe, bitset, &params](
Expand Down

0 comments on commit 2de62cb

Please sign in to comment.