Skip to content
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

Add partitioning_avx2.cpp for PQFastScan #159

Merged
merged 1 commit into from
Oct 19, 2023
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
1 change: 1 addition & 0 deletions cmake/libs/libfaiss.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ knowhere_file_glob(GLOB FAISS_AVX2_SRCS
thirdparty/faiss/faiss/impl/*avx.cpp
thirdparty/faiss/faiss/impl/pq4_fast_scan_search_1.cpp
thirdparty/faiss/faiss/impl/pq4_fast_scan_search_qbs.cpp
thirdparty/faiss/faiss/utils/partitioning_avx2.cpp
thirdparty/faiss/faiss/IndexPQFastScan.cpp
thirdparty/faiss/faiss/IndexIVFPQFastScan.cpp)

Expand Down
4 changes: 2 additions & 2 deletions thirdparty/faiss/faiss/impl/simd_result_handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,15 +427,15 @@ struct ReservoirTopN {

void shrink() {
uint64_t t0 = get_cy();
threshold = partition<C>(vals, ids, i, n);
threshold = partition_avx2<C>(vals, ids, i, n);
i = n;
cycles += get_cy() - t0;
}

void shrink_fuzzy() {
uint64_t t0 = get_cy();
assert(i == capacity);
threshold = partition_fuzzy<C>(
threshold = partition_fuzzy_avx2<C>(
vals, ids, capacity, n, (capacity + n) / 2, &i);
cycles += get_cy() - t0;
}
Expand Down
21 changes: 21 additions & 0 deletions thirdparty/faiss/faiss/utils/partitioning.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,27 @@ inline typename C::T partition(
return partition_fuzzy<C>(vals, ids, n, q, q, nullptr);
}

// avx2 version
template <class C>
typename C::T partition_fuzzy_avx2(
typename C::T* vals,
typename C::TI* ids,
size_t n,
size_t q_min,
size_t q_max,
size_t* q_out);

// avx2 version
/** simplified interface for when the parition is not fuzzy */
template <class C>
inline typename C::T partition_avx2(
typename C::T* vals,
typename C::TI* ids,
size_t n,
size_t q) {
return partition_fuzzy_avx2<C>(vals, ids, n, q, q, nullptr);
}

/** low level SIMD histogramming functions */

/** 8-bin histogram of (x - min) >> shift
Expand Down
Loading
Loading