Skip to content

Commit

Permalink
Setting the OMP thread to 1 while doing the query in Faiss to reduce …
Browse files Browse the repository at this point in the history
…thread creation overhead. (#965) (#967)

Signed-off-by: Navneet Verma <[email protected]>
(cherry picked from commit 3b318ce)

Co-authored-by: Navneet Verma <[email protected]>
  • Loading branch information
opensearch-trigger-bot[bot] and navneet1v authored Jul 11, 2023
1 parent 19965f5 commit 86b812c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions jni/src/faiss_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ jobjectArray knn_jni::faiss_wrapper::QueryIndex_WithFilter(knn_jni::JNIUtilInter
std::vector<float> dis(kJ);
std::vector<faiss::idx_t> ids(kJ);
float* rawQueryvector = jniUtil->GetFloatArrayElements(env, queryVectorJ, nullptr);
/*
Setting the omp_set_num_threads to 1 to make sure that no new OMP threads are getting created.
*/
omp_set_num_threads(1);
// create the filterSearch params if the filterIdsJ is not a null pointer
if(filterIdsJ != nullptr) {
int *filteredIdsArray = jniUtil->GetIntArrayElements(env, filterIdsJ, nullptr);
Expand Down

0 comments on commit 86b812c

Please sign in to comment.