Skip to content
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
2 changes: 1 addition & 1 deletion cmake/libs/libcardinal.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use short SHA1 as version
set(CARDINAL_VERSION v2.5.7 )
set(CARDINAL_VERSION v2.5.8)
set(CARDINAL_REPO_URL "https://github.com/zilliztech/cardinal.git")

set(CARDINAL_REPO_DIR "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/cardinal")
Expand Down
10 changes: 10 additions & 0 deletions include/knowhere/comp/task.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#include <functional>
#include <memory>
#include <vector>

#include "folly/executors/CPUThreadPoolExecutor.h"

namespace knowhere {

void
Expand All @@ -26,6 +29,13 @@ size_t
GetSearchThreadPoolSize();
size_t
GetBuildThreadPoolSize();

folly::CPUThreadPoolExecutor&
GetSearchThreadPool();

folly::CPUThreadPoolExecutor&
GetBuildThreadPool();

class ThreadPool {
public:
class ScopedOmpSetter {
Expand Down
5 changes: 5 additions & 0 deletions include/knowhere/comp/thread_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ class ThreadPool {
return pool_.getPendingTaskCount();
}

folly::CPUThreadPoolExecutor&
GetPool() {
return pool_;
}

void
SetNumThreads(uint32_t num_threads) {
if (num_threads == 0) {
Expand Down
5 changes: 2 additions & 3 deletions python/knowhere/knowhere.i
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ typedef uint64_t size_t;
#include <knowhere/comp/brute_force.h>
#include <knowhere/comp/knowhere_config.h>
#include <knowhere/comp/local_file_manager.h>
#include <knowhere/comp/task.h>
#include <knowhere/comp/index_param.h>
#include <fstream>
#include <string>
Expand Down Expand Up @@ -691,12 +690,12 @@ SetSimdType(const std::string type) {

void
SetBuildThreadPool(uint32_t num_threads) {
knowhere::InitBuildThreadPool(num_threads);
knowhere::KnowhereConfig::SetBuildThreadPoolSize(num_threads);
}

void
SetSearchThreadPool(uint32_t num_threads) {
knowhere::InitSearchThreadPool(num_threads);
knowhere::KnowhereConfig::SetSearchThreadPoolSize(num_threads);
}

%}
Expand Down
11 changes: 11 additions & 0 deletions src/common/thread/thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <thread>
#include <utility>

#include "folly/executors/CPUThreadPoolExecutor.h"
#include "knowhere/comp/thread_pool.h"

namespace knowhere {
Expand Down Expand Up @@ -57,6 +58,16 @@ InitBuildThreadPool(uint32_t num_threads) {
ThreadPool::InitGlobalBuildThreadPool(num_threads);
}

folly::CPUThreadPoolExecutor&
GetBuildThreadPool() {
return ThreadPool::GetGlobalBuildThreadPool()->GetPool();
}

folly::CPUThreadPoolExecutor&
GetSearchThreadPool() {
return ThreadPool::GetGlobalSearchThreadPool()->GetPool();
}

void
InitSearchThreadPool(uint32_t num_threads) {
ThreadPool::InitGlobalSearchThreadPool(num_threads);
Expand Down
Loading