From 7c0c9fb1fb28959faba6454ca2f5c91eec64024b Mon Sep 17 00:00:00 2001 From: Yu Kun Date: Wed, 16 Oct 2019 20:55:55 +0800 Subject: [PATCH] fix clang-format issue Former-commit-id: d28fe86401eaf710f4ac921a29b28b6cab98cea9 --- .../src/scheduler/optimizer/LargeSQ8HPass.cpp | 112 +++++++++--------- core/src/scheduler/optimizer/LargeSQ8HPass.h | 62 +++++----- core/src/scheduler/optimizer/Optimizer.cpp | 12 +- core/src/scheduler/optimizer/Optimizer.h | 4 +- core/src/scheduler/optimizer/Pass.h | 6 +- core/src/scheduler/task/TestTask.cpp | 4 +- core/unittest/scheduler/task_test.cpp | 1 - 7 files changed, 99 insertions(+), 102 deletions(-) diff --git a/core/src/scheduler/optimizer/LargeSQ8HPass.cpp b/core/src/scheduler/optimizer/LargeSQ8HPass.cpp index 95101cee..53372bf4 100644 --- a/core/src/scheduler/optimizer/LargeSQ8HPass.cpp +++ b/core/src/scheduler/optimizer/LargeSQ8HPass.cpp @@ -15,59 +15,59 @@ // specific language governing permissions and limitations // under the License. -//#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" -// -//namespace milvus { -//namespace scheduler { -// -//bool -//LargeSQ8HPass::Run(const TaskPtr& task) { -// if (task->Type() != TaskType::SearchTask) { -// return false; -// } -// -// auto search_task = std::static_pointer_cast(task); -// if (search_task->file_->engine_type_ != (int)engine::EngineType::FAISS_IVFSQ8H) { -// return false; -// } -// -// auto search_job = std::static_pointer_cast(search_task->job_.lock()); -// -// // TODO: future, Index::IVFSQ8H, if nq < threshold set cpu, else set gpu -// if (search_job->nq() < 100) { -// return false; -// } -// -// std::vector gpus = scheduler::get_gpu_pool(); -// std::vector all_free_mem; -// for (auto& gpu : gpus) { -// auto cache = cache::GpuCacheMgr::GetInstance(gpu); -// auto free_mem = cache->CacheCapacity() - cache->CacheUsage(); -// all_free_mem.push_back(free_mem); -// } -// -// auto max_e = std::max_element(all_free_mem.begin(), all_free_mem.end()); -// auto best_index = std::distance(all_free_mem.begin(), max_e); -// auto best_device_id = gpus[best_index]; -// -// ResourcePtr res_ptr = ResMgrInst::GetInstance()->GetResource(ResourceType::GPU, best_device_id); -// if (not res_ptr) { -// SERVER_LOG_ERROR << "GpuResource " << best_device_id << " invalid."; -// // TODO: throw critical error and exit -// return false; -// } -// -// auto label = std::make_shared(std::weak_ptr(res_ptr)); -// task->label() = label; -// -// return true; -//} -// -//} // namespace scheduler -//} // namespace milvus +#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" + +namespace milvus { +namespace scheduler { + +bool +LargeSQ8HPass::Run(const TaskPtr& task) { + // if (task->Type() != TaskType::SearchTask) { + // return false; + // } + // + // auto search_task = std::static_pointer_cast(task); + // if (search_task->file_->engine_type_ != (int)engine::EngineType::FAISS_IVFSQ8H) { + // return false; + // } + // + // auto search_job = std::static_pointer_cast(search_task->job_.lock()); + // + // // TODO: future, Index::IVFSQ8H, if nq < threshold set cpu, else set gpu + // if (search_job->nq() < 100) { + // return false; + // } + // + // std::vector gpus = scheduler::get_gpu_pool(); + // std::vector all_free_mem; + // for (auto& gpu : gpus) { + // auto cache = cache::GpuCacheMgr::GetInstance(gpu); + // auto free_mem = cache->CacheCapacity() - cache->CacheUsage(); + // all_free_mem.push_back(free_mem); + // } + // + // auto max_e = std::max_element(all_free_mem.begin(), all_free_mem.end()); + // auto best_index = std::distance(all_free_mem.begin(), max_e); + // auto best_device_id = gpus[best_index]; + // + // ResourcePtr res_ptr = ResMgrInst::GetInstance()->GetResource(ResourceType::GPU, best_device_id); + // if (not res_ptr) { + // SERVER_LOG_ERROR << "GpuResource " << best_device_id << " invalid."; + // // TODO: throw critical error and exit + // return false; + // } + // + // auto label = std::make_shared(std::weak_ptr(res_ptr)); + // task->label() = label; + // + // return true; +} + +} // namespace scheduler +} // namespace milvus diff --git a/core/src/scheduler/optimizer/LargeSQ8HPass.h b/core/src/scheduler/optimizer/LargeSQ8HPass.h index ca5843ff..49e65800 100644 --- a/core/src/scheduler/optimizer/LargeSQ8HPass.h +++ b/core/src/scheduler/optimizer/LargeSQ8HPass.h @@ -14,34 +14,34 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -//#pragma once -// -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -// -//#include "Pass.h" -// -//namespace milvus { -//namespace scheduler { -// -//class LargeSQ8HPass : public Pass { -// public: -// LargeSQ8HPass() = default; -// -// public: -// bool -// Run(const TaskPtr& task) override; -//}; -// -//using LargeSQ8HPassPtr = std::shared_ptr; -// -//} // namespace scheduler -//} // namespace milvus +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "Pass.h" + +namespace milvus { +namespace scheduler { + +class LargeSQ8HPass : public Pass { + public: + LargeSQ8HPass() = default; + + public: + bool + Run(const TaskPtr& task) override; +}; + +using LargeSQ8HPassPtr = std::shared_ptr; + +} // namespace scheduler +} // namespace milvus diff --git a/core/src/scheduler/optimizer/Optimizer.cpp b/core/src/scheduler/optimizer/Optimizer.cpp index 686352f5..ce0b73d8 100644 --- a/core/src/scheduler/optimizer/Optimizer.cpp +++ b/core/src/scheduler/optimizer/Optimizer.cpp @@ -20,12 +20,12 @@ namespace milvus { namespace scheduler { -//void -//Optimizer::Init() { -// for (auto& pass : pass_list_) { -// pass->Init(); -// } -//} +void +Optimizer::Init() { + // for (auto& pass : pass_list_) { + // pass->Init(); + // } +} bool Optimizer::Run(const TaskPtr& task) { diff --git a/core/src/scheduler/optimizer/Optimizer.h b/core/src/scheduler/optimizer/Optimizer.h index 42fa09ad..68b519e1 100644 --- a/core/src/scheduler/optimizer/Optimizer.h +++ b/core/src/scheduler/optimizer/Optimizer.h @@ -38,8 +38,8 @@ class Optimizer { explicit Optimizer(std::vector pass_list) : pass_list_(std::move(pass_list)) { } -// void -// Init(); + void + Init(); bool Run(const TaskPtr& task); diff --git a/core/src/scheduler/optimizer/Pass.h b/core/src/scheduler/optimizer/Pass.h index 1c74c30d..959c3ea5 100644 --- a/core/src/scheduler/optimizer/Pass.h +++ b/core/src/scheduler/optimizer/Pass.h @@ -34,9 +34,9 @@ namespace scheduler { class Pass { public: -// virtual void -// Init() { -// } + virtual void + Init() { + } virtual bool Run(const TaskPtr& task) = 0; diff --git a/core/src/scheduler/task/TestTask.cpp b/core/src/scheduler/task/TestTask.cpp index 2a9fa61b..3ec3a8ab 100644 --- a/core/src/scheduler/task/TestTask.cpp +++ b/core/src/scheduler/task/TestTask.cpp @@ -44,9 +44,7 @@ TestTask::Execute() { void TestTask::Wait() { std::unique_lock lock(mutex_); - cv_.wait(lock, [&] { - return done_; - }); + cv_.wait(lock, [&] { return done_; }); } } // namespace scheduler diff --git a/core/unittest/scheduler/task_test.cpp b/core/unittest/scheduler/task_test.cpp index 7c2925a7..8ea39ede 100644 --- a/core/unittest/scheduler/task_test.cpp +++ b/core/unittest/scheduler/task_test.cpp @@ -32,7 +32,6 @@ TEST(TaskTest, INVALID_INDEX) { build_task->Load(LoadType::TEST, 10); build_task->Execute(); - } } // namespace scheduler -- GitLab