diff --git a/cpp/src/core/knowhere/knowhere/index/vector_index/IndexIVF.cpp b/cpp/src/core/knowhere/knowhere/index/vector_index/IndexIVF.cpp index 99dd2e2926..0c4856f2b6 100644 --- a/cpp/src/core/knowhere/knowhere/index/vector_index/IndexIVF.cpp +++ b/cpp/src/core/knowhere/knowhere/index/vector_index/IndexIVF.cpp @@ -115,19 +115,18 @@ IVF::Search(const DatasetPtr& dataset, const Config& config) { search_impl(rows, (float*)p_data, search_cfg->k, res_dis, res_ids, config); -// std::stringstream ss_res_id, ss_res_dist; -// for (int i = 0; i < 10; ++i) { -// printf("%llu", res_ids[i]); -// printf("\n"); -// printf("%.6f", res_dis[i]); -// printf("\n"); -// ss_res_id << res_ids[i] << " "; -// ss_res_dist << res_dis[i] << " "; -// } -// std::cout << std::endl << "after search: " << std::endl; -// std::cout << ss_res_id.str() << std::endl; -// std::cout << ss_res_dist.str() << std::endl << std::endl; - + // std::stringstream ss_res_id, ss_res_dist; + // for (int i = 0; i < 10; ++i) { + // printf("%llu", res_ids[i]); + // printf("\n"); + // printf("%.6f", res_dis[i]); + // printf("\n"); + // ss_res_id << res_ids[i] << " "; + // ss_res_dist << res_dis[i] << " "; + // } + // std::cout << std::endl << "after search: " << std::endl; + // std::cout << ss_res_id.str() << std::endl; + // std::cout << ss_res_dist.str() << std::endl << std::endl; auto id_buf = MakeMutableBufferSmart((uint8_t*)res_ids, sizeof(int64_t) * elems); auto dist_buf = MakeMutableBufferSmart((uint8_t*)res_dis, sizeof(float) * elems); diff --git a/cpp/src/core/knowhere/knowhere/index/vector_index/IndexIVFSQHybrid.cpp b/cpp/src/core/knowhere/knowhere/index/vector_index/IndexIVFSQHybrid.cpp index 8176ee0b49..268b7fb9e3 100644 --- a/cpp/src/core/knowhere/knowhere/index/vector_index/IndexIVFSQHybrid.cpp +++ b/cpp/src/core/knowhere/knowhere/index/vector_index/IndexIVFSQHybrid.cpp @@ -17,6 +17,7 @@ // under the License. #include "knowhere/index/vector_index/IndexIVFSQHybrid.h" +#include #include "faiss/AutoTune.h" #include "faiss/gpu/GpuAutoTune.h" #include "faiss/gpu/GpuIndexIVF.h" @@ -176,9 +177,9 @@ IVFSQHybrid::LoadData(const knowhere::QuantizerPtr& q, const Config& conf) { KNOWHERE_THROW_MSG("mode only support 2 in this func"); } } -// if (quantizer_conf->gpu_id != gpu_id_) { -// KNOWHERE_THROW_MSG("quantizer and data must on the same gpu card"); -// } + // if (quantizer_conf->gpu_id != gpu_id_) { + // KNOWHERE_THROW_MSG("quantizer and data must on the same gpu card"); + // } gpu_id_ = quantizer_conf->gpu_id; if (auto res = FaissGpuResourceMgr::GetInstance().GetRes(gpu_id_)) { @@ -208,7 +209,6 @@ IVFSQHybrid::LoadData(const knowhere::QuantizerPtr& q, const Config& conf) { std::pair IVFSQHybrid::CopyCpuToGpuWithQuantizer(const int64_t& device_id, const Config& config) { if (auto res = FaissGpuResourceMgr::GetInstance().GetRes(device_id)) { - ResScope rs(res, device_id, false); faiss::gpu::GpuClonerOptions option; option.allInGpu = true; @@ -222,7 +222,7 @@ IVFSQHybrid::CopyCpuToGpuWithQuantizer(const int64_t& device_id, const Config& c std::shared_ptr device_index; device_index.reset(gpu_index); - auto new_idx = std::make_shared(device_index, device_id, res); + auto new_idx = std::make_shared(device_index, device_id, res); auto q = std::make_shared(); q->quantizer = index_composition.quantizer; diff --git a/cpp/src/core/knowhere/knowhere/index/vector_index/IndexIVFSQHybrid.h b/cpp/src/core/knowhere/knowhere/index/vector_index/IndexIVFSQHybrid.h index cc59940028..f54c61c20f 100644 --- a/cpp/src/core/knowhere/knowhere/index/vector_index/IndexIVFSQHybrid.h +++ b/cpp/src/core/knowhere/knowhere/index/vector_index/IndexIVFSQHybrid.h @@ -19,6 +19,7 @@ #include #include +#include #include "IndexGPUIVFSQ.h" #include "Quantizer.h" diff --git a/cpp/src/db/engine/ExecutionEngine.h b/cpp/src/db/engine/ExecutionEngine.h index 5246fa1e2c..2c4960e6ac 100644 --- a/cpp/src/db/engine/ExecutionEngine.h +++ b/cpp/src/db/engine/ExecutionEngine.h @@ -80,7 +80,8 @@ class ExecutionEngine { Merge(const std::string& location) = 0; virtual Status - Search(int64_t n, const float* data, int64_t k, int64_t nprobe, float* distances, int64_t* labels, bool hybrid) const = 0; + Search(int64_t n, const float* data, int64_t k, int64_t nprobe, float* distances, int64_t* labels, + bool hybrid) const = 0; virtual std::shared_ptr BuildIndex(const std::string& location, EngineType engine_type) = 0; diff --git a/cpp/src/db/engine/ExecutionEngineImpl.cpp b/cpp/src/db/engine/ExecutionEngineImpl.cpp index 5b2c8eb2f3..3fa68aae52 100644 --- a/cpp/src/db/engine/ExecutionEngineImpl.cpp +++ b/cpp/src/db/engine/ExecutionEngineImpl.cpp @@ -31,11 +31,11 @@ #include "wrapper/ConfAdapter.h" #include "wrapper/ConfAdapterMgr.h" +#include #include #include #include #include -#include namespace milvus { namespace engine { @@ -414,8 +414,8 @@ ExecutionEngineImpl::BuildIndex(const std::string& location, EngineType engine_t } Status -ExecutionEngineImpl::Search(int64_t n, const float* data, int64_t k, int64_t nprobe, float* distances, - int64_t* labels, bool hybrid) const { +ExecutionEngineImpl::Search(int64_t n, const float* data, int64_t k, int64_t nprobe, float* distances, int64_t* labels, + bool hybrid) const { if (index_ == nullptr) { ENGINE_LOG_ERROR << "ExecutionEngineImpl: index is null, failed to search"; return Status(DB_ERROR, "index is null"); diff --git a/cpp/src/db/engine/ExecutionEngineImpl.h b/cpp/src/db/engine/ExecutionEngineImpl.h index 8ac7bc4d51..9cbabb2bd5 100644 --- a/cpp/src/db/engine/ExecutionEngineImpl.h +++ b/cpp/src/db/engine/ExecutionEngineImpl.h @@ -71,12 +71,7 @@ class ExecutionEngineImpl : public ExecutionEngine { Merge(const std::string& location) override; Status - Search(int64_t n, - const float* data, - int64_t k, - int64_t nprobe, - float* distances, - int64_t* labels, + Search(int64_t n, const float* data, int64_t k, int64_t nprobe, float* distances, int64_t* labels, bool hybrid = false) const override; ExecutionEnginePtr diff --git a/cpp/src/scheduler/JobMgr.cpp b/cpp/src/scheduler/JobMgr.cpp index fb63671f37..70f1352a5c 100644 --- a/cpp/src/scheduler/JobMgr.cpp +++ b/cpp/src/scheduler/JobMgr.cpp @@ -19,10 +19,10 @@ #include "SchedInst.h" #include "TaskCreator.h" #include "optimizer/Optimizer.h" -#include "task/Task.h" -#include "scheduler/tasklabel/SpecResLabel.h" -#include "scheduler/optimizer/Optimizer.h" #include "scheduler/Algorithm.h" +#include "scheduler/optimizer/Optimizer.h" +#include "scheduler/tasklabel/SpecResLabel.h" +#include "task/Task.h" #include @@ -62,9 +62,7 @@ void JobMgr::worker_function() { while (running_) { std::unique_lock lock(mutex_); - cv_.wait(lock, [this] { - return !queue_.empty(); - }); + cv_.wait(lock, [this] { return !queue_.empty(); }); auto job = queue_.front(); queue_.pop(); lock.unlock(); @@ -77,7 +75,7 @@ JobMgr::worker_function() { OptimizerInst::GetInstance()->Run(task); } - for (auto& task: tasks) { + for (auto& task : tasks) { calculate_path(task); } diff --git a/cpp/src/scheduler/action/PushTaskToNeighbour.cpp b/cpp/src/scheduler/action/PushTaskToNeighbour.cpp index 442cccd538..b42234d0f6 100644 --- a/cpp/src/scheduler/action/PushTaskToNeighbour.cpp +++ b/cpp/src/scheduler/action/PushTaskToNeighbour.cpp @@ -145,37 +145,38 @@ Action::SpecifiedResourceLabelTaskScheduler(ResourceMgrWPtr res_mgr, ResourcePtr transport_costs.push_back(transport_cost); paths.emplace_back(path); } -// if (task->job_.lock()->type() == JobType::SEARCH) { -// auto label = task->label(); -// auto spec_label = std::static_pointer_cast(label); -// if (spec_label->resource().lock()->type() == ResourceType::CPU) { -// std::vector spec_path; -// spec_path.push_back(spec_label->resource().lock()->name()); -// spec_path.push_back(resource->name()); -// task->path() = Path(spec_path, spec_path.size() - 1); -// } else { -// // step 2: select min cost, cost(resource) = avg_cost * task_to_do + transport_cost -// uint64_t min_cost = std::numeric_limits::max(); -// uint64_t min_cost_idx = 0; -// for (uint64_t i = 0; i < compute_resources.size(); ++i) { -// if (compute_resources[i]->TotalTasks() == 0) { -// min_cost_idx = i; -// break; -// } -// uint64_t cost = compute_resources[i]->TaskAvgCost() * compute_resources[i]->NumOfTaskToExec() + -// transport_costs[i]; -// if (min_cost > cost) { -// min_cost = cost; -// min_cost_idx = i; -// } -// } -// -// // step 3: set path in task -// Path task_path(paths[min_cost_idx], paths[min_cost_idx].size() - 1); -// task->path() = task_path; -// } -// -// } else + // if (task->job_.lock()->type() == JobType::SEARCH) { + // auto label = task->label(); + // auto spec_label = std::static_pointer_cast(label); + // if (spec_label->resource().lock()->type() == ResourceType::CPU) { + // std::vector spec_path; + // spec_path.push_back(spec_label->resource().lock()->name()); + // spec_path.push_back(resource->name()); + // task->path() = Path(spec_path, spec_path.size() - 1); + // } else { + // // step 2: select min cost, cost(resource) = avg_cost * task_to_do + transport_cost + // uint64_t min_cost = std::numeric_limits::max(); + // uint64_t min_cost_idx = 0; + // for (uint64_t i = 0; i < compute_resources.size(); ++i) { + // if (compute_resources[i]->TotalTasks() == 0) { + // min_cost_idx = i; + // break; + // } + // uint64_t cost = compute_resources[i]->TaskAvgCost() * + // compute_resources[i]->NumOfTaskToExec() + + // transport_costs[i]; + // if (min_cost > cost) { + // min_cost = cost; + // min_cost_idx = i; + // } + // } + // + // // step 3: set path in task + // Path task_path(paths[min_cost_idx], paths[min_cost_idx].size() - 1); + // task->path() = task_path; + // } + // + // } else if (task->job_.lock()->type() == JobType::BUILD) { // step2: Read device id in config // get build index gpu resource diff --git a/cpp/src/scheduler/optimizer/LargeSQ8HPass.cpp b/cpp/src/scheduler/optimizer/LargeSQ8HPass.cpp index 65f431bd90..62d0e57902 100644 --- a/cpp/src/scheduler/optimizer/LargeSQ8HPass.cpp +++ b/cpp/src/scheduler/optimizer/LargeSQ8HPass.cpp @@ -15,10 +15,10 @@ // specific language governing permissions and limitations // under the License. -#include "cache/GpuCacheMgr.h" -#include "scheduler/Utils.h" #include "scheduler/optimizer/LargeSQ8HPass.h" +#include "cache/GpuCacheMgr.h" #include "scheduler/SchedInst.h" +#include "scheduler/Utils.h" #include "scheduler/task/SearchTask.h" #include "scheduler/tasklabel/SpecResLabel.h" #include "utils/Log.h" diff --git a/cpp/src/scheduler/resource/Resource.cpp b/cpp/src/scheduler/resource/Resource.cpp index 14eb085f7f..0228d2881b 100644 --- a/cpp/src/scheduler/resource/Resource.cpp +++ b/cpp/src/scheduler/resource/Resource.cpp @@ -19,6 +19,7 @@ #include "scheduler/Utils.h" #include +#include #include namespace milvus { @@ -126,9 +127,7 @@ void Resource::loader_function() { while (running_) { std::unique_lock lock(load_mutex_); - load_cv_.wait(lock, [&] { - return load_flag_; - }); + load_cv_.wait(lock, [&] { return load_flag_; }); load_flag_ = false; lock.unlock(); while (true) { @@ -154,9 +153,7 @@ Resource::executor_function() { } while (running_) { std::unique_lock lock(exec_mutex_); - exec_cv_.wait(lock, [&] { - return exec_flag_; - }); + exec_cv_.wait(lock, [&] { return exec_flag_; }); exec_flag_ = false; lock.unlock(); while (true) { diff --git a/cpp/src/scheduler/task/SearchTask.cpp b/cpp/src/scheduler/task/SearchTask.cpp index c5fb2f661f..b7e27e4944 100644 --- a/cpp/src/scheduler/task/SearchTask.cpp +++ b/cpp/src/scheduler/task/SearchTask.cpp @@ -22,11 +22,11 @@ #include "utils/Log.h" #include "utils/TimeRecorder.h" +#include #include #include #include #include -#include namespace milvus { namespace scheduler { diff --git a/cpp/src/wrapper/VecImpl.h b/cpp/src/wrapper/VecImpl.h index 84b2f11564..22d734cf92 100644 --- a/cpp/src/wrapper/VecImpl.h +++ b/cpp/src/wrapper/VecImpl.h @@ -105,8 +105,8 @@ class IVFHybridIndex : public IVFMixIndex { Status UnsetQuantizer() override; - std::pair CopyToGpuWithQuantizer(const int64_t& device_id, - const Config& cfg) override; + std::pair + CopyToGpuWithQuantizer(const int64_t& device_id, const Config& cfg) override; VecIndexPtr LoadData(const knowhere::QuantizerPtr& q, const Config& conf) override; diff --git a/cpp/src/wrapper/VecIndex.h b/cpp/src/wrapper/VecIndex.h index e52c26f0bf..05da9ccc03 100644 --- a/cpp/src/wrapper/VecIndex.h +++ b/cpp/src/wrapper/VecIndex.h @@ -19,6 +19,7 @@ #include #include +#include #include "cache/DataObj.h" #include "knowhere/common/BinarySet.h"