From 4847e5027f0aeeace69d02d1a4e1410b9b52a1c6 Mon Sep 17 00:00:00 2001 From: Wang XiangYu Date: Mon, 9 Dec 2019 19:09:14 +0800 Subject: [PATCH] Remove unused codes (#732) * remove unused function and comments * remove always-true parameter * run on python2 explicitly * fix clang-format --- core/build-support/run_clang_format.py | 2 +- core/src/scheduler/ResourceFactory.cpp | 9 ++- core/src/scheduler/ResourceFactory.h | 3 +- core/src/scheduler/SchedInst.cpp | 9 ++- core/src/scheduler/Scheduler.cpp | 14 ++--- core/src/scheduler/Scheduler.h | 44 +------------ core/src/scheduler/TaskTable.h | 3 - core/src/scheduler/Utils.cpp | 9 --- core/src/scheduler/Utils.h | 3 - core/src/scheduler/resource/CpuResource.cpp | 4 +- core/src/scheduler/resource/CpuResource.h | 2 +- core/src/scheduler/resource/DiskResource.cpp | 4 +- core/src/scheduler/resource/DiskResource.h | 2 +- core/src/scheduler/resource/GpuResource.cpp | 4 +- core/src/scheduler/resource/GpuResource.h | 2 +- core/src/scheduler/resource/Resource.cpp | 19 ++---- core/src/scheduler/resource/Resource.h | 8 +-- core/src/scheduler/resource/TestResource.cpp | 4 +- core/src/scheduler/resource/TestResource.h | 2 +- core/unittest/db/utils.cpp | 6 +- core/unittest/scheduler/test_algorithm.cpp | 4 +- core/unittest/scheduler/test_resource.cpp | 61 ++++++------------- core/unittest/scheduler/test_resource_mgr.cpp | 22 +++---- core/unittest/scheduler/test_scheduler.cpp | 24 ++++---- core/unittest/server/test_rpc.cpp | 6 +- 25 files changed, 85 insertions(+), 185 deletions(-) diff --git a/core/build-support/run_clang_format.py b/core/build-support/run_clang_format.py index 4c7fdfb2af..cb5afaba4a 100755 --- a/core/build-support/run_clang_format.py +++ b/core/build-support/run_clang_format.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information diff --git a/core/src/scheduler/ResourceFactory.cpp b/core/src/scheduler/ResourceFactory.cpp index fad8571b61..edbedeb967 100644 --- a/core/src/scheduler/ResourceFactory.cpp +++ b/core/src/scheduler/ResourceFactory.cpp @@ -21,14 +21,13 @@ namespace milvus { namespace scheduler { std::shared_ptr -ResourceFactory::Create(const std::string& name, const std::string& type, uint64_t device_id, bool enable_loader, - bool enable_executor) { +ResourceFactory::Create(const std::string& name, const std::string& type, uint64_t device_id, bool enable_executor) { if (type == "DISK") { - return std::make_shared(name, device_id, enable_loader, enable_executor); + return std::make_shared(name, device_id, enable_executor); } else if (type == "CPU") { - return std::make_shared(name, device_id, enable_loader, enable_executor); + return std::make_shared(name, device_id, enable_executor); } else if (type == "GPU") { - return std::make_shared(name, device_id, enable_loader, enable_executor); + return std::make_shared(name, device_id, enable_executor); } else { return nullptr; } diff --git a/core/src/scheduler/ResourceFactory.h b/core/src/scheduler/ResourceFactory.h index 3290cb023c..9414869ef7 100644 --- a/core/src/scheduler/ResourceFactory.h +++ b/core/src/scheduler/ResourceFactory.h @@ -31,8 +31,7 @@ namespace scheduler { class ResourceFactory { public: static std::shared_ptr - Create(const std::string& name, const std::string& type, uint64_t device_id, bool enable_loader = true, - bool enable_executor = true); + Create(const std::string& name, const std::string& type, uint64_t device_id, bool enable_executor = true); }; } // namespace scheduler diff --git a/core/src/scheduler/SchedInst.cpp b/core/src/scheduler/SchedInst.cpp index f86b6f44b3..f297c78467 100644 --- a/core/src/scheduler/SchedInst.cpp +++ b/core/src/scheduler/SchedInst.cpp @@ -46,10 +46,10 @@ std::mutex BuildMgrInst::mutex_; void load_simple_config() { // create and connect - ResMgrInst::GetInstance()->Add(ResourceFactory::Create("disk", "DISK", 0, true, false)); + ResMgrInst::GetInstance()->Add(ResourceFactory::Create("disk", "DISK", 0, false)); auto io = Connection("io", 500); - ResMgrInst::GetInstance()->Add(ResourceFactory::Create("cpu", "CPU", 0, true, true)); + ResMgrInst::GetInstance()->Add(ResourceFactory::Create("cpu", "CPU", 0)); ResMgrInst::GetInstance()->Connect("disk", "cpu", io); // get resources @@ -79,13 +79,12 @@ load_simple_config() { } for (auto& gpu_id : gpu_ids) { - ResMgrInst::GetInstance()->Add(ResourceFactory::Create(std::to_string(gpu_id), "GPU", gpu_id, true, true)); + ResMgrInst::GetInstance()->Add(ResourceFactory::Create(std::to_string(gpu_id), "GPU", gpu_id)); ResMgrInst::GetInstance()->Connect("cpu", std::to_string(gpu_id), pcie); } for (auto& not_find_id : not_find_build_ids) { - ResMgrInst::GetInstance()->Add( - ResourceFactory::Create(std::to_string(not_find_id), "GPU", not_find_id, true, true)); + ResMgrInst::GetInstance()->Add(ResourceFactory::Create(std::to_string(not_find_id), "GPU", not_find_id)); ResMgrInst::GetInstance()->Connect("cpu", std::to_string(not_find_id), pcie); } } diff --git a/core/src/scheduler/Scheduler.cpp b/core/src/scheduler/Scheduler.cpp index 68d7457aa9..5450502c5a 100644 --- a/core/src/scheduler/Scheduler.cpp +++ b/core/src/scheduler/Scheduler.cpp @@ -77,6 +77,12 @@ Scheduler::Dump() const { return ret; } +void +Scheduler::process(const EventPtr& event) { + auto process_event = event_register_.at(static_cast(event->Type())); + process_event(event); +} + void Scheduler::worker_function() { while (running_) { @@ -88,16 +94,10 @@ Scheduler::worker_function() { break; } - Process(event); + process(event); } } -void -Scheduler::Process(const EventPtr& event) { - auto process_event = event_register_.at(static_cast(event->Type())); - process_event(event); -} - // TODO(wxyu): refactor the function void Scheduler::OnLoadCompleted(const EventPtr& event) { diff --git a/core/src/scheduler/Scheduler.h b/core/src/scheduler/Scheduler.h index 9e3a864774..0efeace650 100644 --- a/core/src/scheduler/Scheduler.h +++ b/core/src/scheduler/Scheduler.h @@ -41,21 +41,12 @@ class Scheduler : public interface::dumpable { Scheduler(const Scheduler&) = delete; Scheduler(Scheduler&&) = delete; - /* - * Start worker thread; - */ void Start(); - /* - * Stop worker thread, join it; - */ void Stop(); - /* - * Post event to scheduler event queue; - */ void PostEvent(const EventPtr& event); @@ -63,55 +54,22 @@ class Scheduler : public interface::dumpable { Dump() const override; private: - /******** Events ********/ - - /* - * Process start up events; - * - * Actions: - * Pull task from neighbours; - */ void OnStartUp(const EventPtr& event); - /* - * Process finish task events; - * - * Actions: - * Pull task from neighbours; - */ void OnFinishTask(const EventPtr& event); - /* - * Process copy completed events; - * - * Actions: - * Mark task source MOVED; - * Pull task from neighbours; - */ void OnLoadCompleted(const EventPtr& event); - /* - * Process task table updated events, which happened on task_table->put; - * - * Actions: - * Push task to neighbours; - */ void OnTaskTableUpdated(const EventPtr& event); private: - /* - * Dispatch event to event handler; - */ void - Process(const EventPtr& event); + process(const EventPtr& event); - /* - * Called by worker_thread_; - */ void worker_function(); diff --git a/core/src/scheduler/TaskTable.h b/core/src/scheduler/TaskTable.h index 37e2747343..5717225150 100644 --- a/core/src/scheduler/TaskTable.h +++ b/core/src/scheduler/TaskTable.h @@ -119,9 +119,6 @@ class TaskTable : public interface::dumpable { subscriber_ = std::move(subscriber); } - /* - * Put one task; - */ void Put(TaskPtr task, TaskTableItemPtr from = nullptr); diff --git a/core/src/scheduler/Utils.cpp b/core/src/scheduler/Utils.cpp index 527b9adf03..9af9368d5a 100644 --- a/core/src/scheduler/Utils.cpp +++ b/core/src/scheduler/Utils.cpp @@ -35,14 +35,5 @@ get_current_timestamp() { return millis; } -uint64_t -get_num_gpu() { - int n_devices = 0; -#ifdef MILVUS_GPU_VERSION - cudaGetDeviceCount(&n_devices); -#endif - return n_devices; -} - } // namespace scheduler } // namespace milvus diff --git a/core/src/scheduler/Utils.h b/core/src/scheduler/Utils.h index bf88cf0345..ed9bacb77a 100644 --- a/core/src/scheduler/Utils.h +++ b/core/src/scheduler/Utils.h @@ -24,8 +24,5 @@ namespace scheduler { uint64_t get_current_timestamp(); -uint64_t -get_num_gpu(); - } // namespace scheduler } // namespace milvus diff --git a/core/src/scheduler/resource/CpuResource.cpp b/core/src/scheduler/resource/CpuResource.cpp index eb43a863cc..f436af3d4f 100644 --- a/core/src/scheduler/resource/CpuResource.cpp +++ b/core/src/scheduler/resource/CpuResource.cpp @@ -28,8 +28,8 @@ operator<<(std::ostream& out, const CpuResource& resource) { return out; } -CpuResource::CpuResource(std::string name, uint64_t device_id, bool enable_loader, bool enable_executor) - : Resource(std::move(name), ResourceType::CPU, device_id, enable_loader, enable_executor) { +CpuResource::CpuResource(std::string name, uint64_t device_id, bool enable_executor) + : Resource(std::move(name), ResourceType::CPU, device_id, enable_executor) { } void diff --git a/core/src/scheduler/resource/CpuResource.h b/core/src/scheduler/resource/CpuResource.h index 10cd88ea2d..0f070c135b 100644 --- a/core/src/scheduler/resource/CpuResource.h +++ b/core/src/scheduler/resource/CpuResource.h @@ -26,7 +26,7 @@ namespace scheduler { class CpuResource : public Resource { public: - explicit CpuResource(std::string name, uint64_t device_id, bool enable_loader, bool enable_executor); + explicit CpuResource(std::string name, uint64_t device_id, bool enable_executor); friend std::ostream& operator<<(std::ostream& out, const CpuResource& resource); diff --git a/core/src/scheduler/resource/DiskResource.cpp b/core/src/scheduler/resource/DiskResource.cpp index fe1fc9c8d9..0085f7d11c 100644 --- a/core/src/scheduler/resource/DiskResource.cpp +++ b/core/src/scheduler/resource/DiskResource.cpp @@ -29,8 +29,8 @@ operator<<(std::ostream& out, const DiskResource& resource) { return out; } -DiskResource::DiskResource(std::string name, uint64_t device_id, bool enable_loader, bool enable_executor) - : Resource(std::move(name), ResourceType::DISK, device_id, enable_loader, enable_executor) { +DiskResource::DiskResource(std::string name, uint64_t device_id, bool enable_executor) + : Resource(std::move(name), ResourceType::DISK, device_id, enable_executor) { } void diff --git a/core/src/scheduler/resource/DiskResource.h b/core/src/scheduler/resource/DiskResource.h index 384e44b4f2..a0cbb405bf 100644 --- a/core/src/scheduler/resource/DiskResource.h +++ b/core/src/scheduler/resource/DiskResource.h @@ -26,7 +26,7 @@ namespace scheduler { class DiskResource : public Resource { public: - explicit DiskResource(std::string name, uint64_t device_id, bool enable_loader, bool enable_executor); + explicit DiskResource(std::string name, uint64_t device_id, bool enable_executor); friend std::ostream& operator<<(std::ostream& out, const DiskResource& resource); diff --git a/core/src/scheduler/resource/GpuResource.cpp b/core/src/scheduler/resource/GpuResource.cpp index f6363ff01d..8269b5d1d3 100644 --- a/core/src/scheduler/resource/GpuResource.cpp +++ b/core/src/scheduler/resource/GpuResource.cpp @@ -26,8 +26,8 @@ operator<<(std::ostream& out, const GpuResource& resource) { return out; } -GpuResource::GpuResource(std::string name, uint64_t device_id, bool enable_loader, bool enable_executor) - : Resource(std::move(name), ResourceType::GPU, device_id, enable_loader, enable_executor) { +GpuResource::GpuResource(std::string name, uint64_t device_id, bool enable_executor) + : Resource(std::move(name), ResourceType::GPU, device_id, enable_executor) { } void diff --git a/core/src/scheduler/resource/GpuResource.h b/core/src/scheduler/resource/GpuResource.h index 86b3b6658c..faae47ac76 100644 --- a/core/src/scheduler/resource/GpuResource.h +++ b/core/src/scheduler/resource/GpuResource.h @@ -27,7 +27,7 @@ namespace scheduler { class GpuResource : public Resource { public: - explicit GpuResource(std::string name, uint64_t device_id, bool enable_loader, bool enable_executor); + explicit GpuResource(std::string name, uint64_t device_id, bool enable_executor); friend std::ostream& operator<<(std::ostream& out, const GpuResource& resource); diff --git a/core/src/scheduler/resource/Resource.cpp b/core/src/scheduler/resource/Resource.cpp index 596d7da468..2cf9047b72 100644 --- a/core/src/scheduler/resource/Resource.cpp +++ b/core/src/scheduler/resource/Resource.cpp @@ -48,12 +48,8 @@ ToString(ResourceType type) { } } -Resource::Resource(std::string name, ResourceType type, uint64_t device_id, bool enable_loader, bool enable_executor) - : name_(std::move(name)), - type_(type), - device_id_(device_id), - enable_loader_(enable_loader), - enable_executor_(enable_executor) { +Resource::Resource(std::string name, ResourceType type, uint64_t device_id, bool enable_executor) + : name_(std::move(name)), type_(type), device_id_(device_id), enable_executor_(enable_executor) { // register subscriber in tasktable task_table_.RegisterSubscriber([&] { if (subscriber_) { @@ -66,9 +62,7 @@ Resource::Resource(std::string name, ResourceType type, uint64_t device_id, bool void Resource::Start() { running_ = true; - if (enable_loader_) { - loader_thread_ = std::thread(&Resource::loader_function, this); - } + loader_thread_ = std::thread(&Resource::loader_function, this); if (enable_executor_) { executor_thread_ = std::thread(&Resource::executor_function, this); } @@ -77,10 +71,8 @@ Resource::Start() { void Resource::Stop() { running_ = false; - if (enable_loader_) { - WakeupLoader(); - loader_thread_.join(); - } + WakeupLoader(); + loader_thread_.join(); if (enable_executor_) { WakeupExecutor(); executor_thread_.join(); @@ -115,7 +107,6 @@ Resource::Dump() const { {"task_total_cost", total_cost_}, {"total_tasks", total_task_}, {"running", running_}, - {"enable_loader", enable_loader_}, {"enable_executor", enable_executor_}, }; return ret; diff --git a/core/src/scheduler/resource/Resource.h b/core/src/scheduler/resource/Resource.h index 2af44b3d90..22e0076cf9 100644 --- a/core/src/scheduler/resource/Resource.h +++ b/core/src/scheduler/resource/Resource.h @@ -102,11 +102,6 @@ class Resource : public Node, public std::enable_shared_from_this { } public: - inline bool - HasLoader() const { - return enable_loader_; - } - inline bool HasExecutor() const { return enable_executor_; @@ -134,7 +129,7 @@ class Resource : public Node, public std::enable_shared_from_this { operator<<(std::ostream& out, const Resource& resource); protected: - Resource(std::string name, ResourceType type, uint64_t device_id, bool enable_loader, bool enable_executor); + Resource(std::string name, ResourceType type, uint64_t device_id, bool enable_executor); /* * Implementation by inherit class; @@ -193,7 +188,6 @@ class Resource : public Node, public std::enable_shared_from_this { std::function subscriber_ = nullptr; bool running_ = false; - bool enable_loader_ = true; bool enable_executor_ = true; std::thread loader_thread_; std::thread executor_thread_; diff --git a/core/src/scheduler/resource/TestResource.cpp b/core/src/scheduler/resource/TestResource.cpp index c8c2fb7537..1db34c5493 100644 --- a/core/src/scheduler/resource/TestResource.cpp +++ b/core/src/scheduler/resource/TestResource.cpp @@ -28,8 +28,8 @@ operator<<(std::ostream& out, const TestResource& resource) { return out; } -TestResource::TestResource(std::string name, uint64_t device_id, bool enable_loader, bool enable_executor) - : Resource(std::move(name), ResourceType::TEST, device_id, enable_loader, enable_executor) { +TestResource::TestResource(std::string name, uint64_t device_id, bool enable_executor) + : Resource(std::move(name), ResourceType::TEST, device_id, enable_executor) { } void diff --git a/core/src/scheduler/resource/TestResource.h b/core/src/scheduler/resource/TestResource.h index 4e4e148d6f..601e8648f2 100644 --- a/core/src/scheduler/resource/TestResource.h +++ b/core/src/scheduler/resource/TestResource.h @@ -27,7 +27,7 @@ namespace scheduler { class TestResource : public Resource { public: - explicit TestResource(std::string name, uint64_t device_id, bool enable_loader, bool enable_executor); + explicit TestResource(std::string name, uint64_t device_id, bool enable_executor); friend std::ostream& operator<<(std::ostream& out, const TestResource& resource); diff --git a/core/unittest/db/utils.cpp b/core/unittest/db/utils.cpp index a57bae79b5..a5231f19cf 100644 --- a/core/unittest/db/utils.cpp +++ b/core/unittest/db/utils.cpp @@ -152,14 +152,14 @@ DBTest::SetUp() { auto res_mgr = milvus::scheduler::ResMgrInst::GetInstance(); res_mgr->Clear(); - res_mgr->Add(milvus::scheduler::ResourceFactory::Create("disk", "DISK", 0, true, false)); - res_mgr->Add(milvus::scheduler::ResourceFactory::Create("cpu", "CPU", 0, true, true)); + res_mgr->Add(milvus::scheduler::ResourceFactory::Create("disk", "DISK", 0, false)); + res_mgr->Add(milvus::scheduler::ResourceFactory::Create("cpu", "CPU", 0)); auto default_conn = milvus::scheduler::Connection("IO", 500.0); auto PCIE = milvus::scheduler::Connection("IO", 11000.0); res_mgr->Connect("disk", "cpu", default_conn); #ifdef MILVUS_GPU_VERSION - res_mgr->Add(milvus::scheduler::ResourceFactory::Create("0", "GPU", 0, true, true)); + res_mgr->Add(milvus::scheduler::ResourceFactory::Create("0", "GPU", 0)); res_mgr->Connect("cpu", "0", PCIE); #endif res_mgr->Start(); diff --git a/core/unittest/scheduler/test_algorithm.cpp b/core/unittest/scheduler/test_algorithm.cpp index 7517a9b879..310ea5ba9c 100644 --- a/core/unittest/scheduler/test_algorithm.cpp +++ b/core/unittest/scheduler/test_algorithm.cpp @@ -30,8 +30,8 @@ class AlgorithmTest : public testing::Test { protected: void SetUp() override { - ResourcePtr disk = ResourceFactory::Create("disk", "DISK", 0, true, false); - ResourcePtr cpu0 = ResourceFactory::Create("cpu0", "CPU", 0, true, true); + ResourcePtr disk = ResourceFactory::Create("disk", "DISK", 0, false); + ResourcePtr cpu0 = ResourceFactory::Create("cpu0", "CPU", 0); ResourcePtr cpu1 = ResourceFactory::Create("cpu1", "CPU", 1); ResourcePtr cpu2 = ResourceFactory::Create("cpu2", "CPU", 2); ResourcePtr gpu0 = ResourceFactory::Create("gpu0", "GPU", 0); diff --git a/core/unittest/scheduler/test_resource.cpp b/core/unittest/scheduler/test_resource.cpp index 101dcd3976..f6371b6920 100644 --- a/core/unittest/scheduler/test_resource.cpp +++ b/core/unittest/scheduler/test_resource.cpp @@ -36,69 +36,44 @@ class ResourceBaseTest : public testing::Test { protected: void SetUp() override { - only_loader_ = std::make_shared(name1, id1, true, false); - only_executor_ = std::make_shared(name2, id2, false, true); - both_enable_ = std::make_shared(name3, id3, true, true); - both_disable_ = std::make_shared(name4, id4, false, false); + enable_executor_ = std::make_shared(name1, id1, true); + disable_executor_ = std::make_shared(name2, id2, false); } - const std::string name1 = "only_loader_"; - const std::string name2 = "only_executor_"; - const std::string name3 = "both_enable_"; - const std::string name4 = "both_disable_"; + const std::string name1 = "enable_executor_"; + const std::string name2 = "disable_executor_"; const uint64_t id1 = 1; const uint64_t id2 = 2; - const uint64_t id3 = 3; - const uint64_t id4 = 4; - ResourcePtr only_loader_ = nullptr; - ResourcePtr only_executor_ = nullptr; - ResourcePtr both_enable_ = nullptr; - ResourcePtr both_disable_ = nullptr; + ResourcePtr enable_executor_ = nullptr; + ResourcePtr disable_executor_ = nullptr; }; TEST_F(ResourceBaseTest, NAME) { - ASSERT_EQ(only_loader_->name(), name1); - ASSERT_EQ(only_executor_->name(), name2); - ASSERT_EQ(both_enable_->name(), name3); - ASSERT_EQ(both_disable_->name(), name4); + ASSERT_EQ(enable_executor_->name(), name1); + ASSERT_EQ(disable_executor_->name(), name2); } TEST_F(ResourceBaseTest, TYPE) { - ASSERT_EQ(only_loader_->type(), ResourceType::DISK); - ASSERT_EQ(only_executor_->type(), ResourceType::CPU); - ASSERT_EQ(both_enable_->type(), ResourceType::GPU); - ASSERT_EQ(both_disable_->type(), ResourceType::TEST); + ASSERT_EQ(enable_executor_->type(), ResourceType::CPU); + ASSERT_EQ(disable_executor_->type(), ResourceType::GPU); } TEST_F(ResourceBaseTest, DEVICE_ID) { - ASSERT_EQ(only_loader_->device_id(), id1); - ASSERT_EQ(only_executor_->device_id(), id2); - ASSERT_EQ(both_enable_->device_id(), id3); - ASSERT_EQ(both_disable_->device_id(), id4); -} - -TEST_F(ResourceBaseTest, HAS_LOADER) { - ASSERT_TRUE(only_loader_->HasLoader()); - ASSERT_FALSE(only_executor_->HasLoader()); - ASSERT_TRUE(both_enable_->HasLoader()); - ASSERT_FALSE(both_disable_->HasLoader()); + ASSERT_EQ(enable_executor_->device_id(), id1); + ASSERT_EQ(disable_executor_->device_id(), id2); } TEST_F(ResourceBaseTest, HAS_EXECUTOR) { - ASSERT_FALSE(only_loader_->HasExecutor()); - ASSERT_TRUE(only_executor_->HasExecutor()); - ASSERT_TRUE(both_enable_->HasExecutor()); - ASSERT_FALSE(both_disable_->HasExecutor()); + ASSERT_TRUE(enable_executor_->HasExecutor()); + ASSERT_FALSE(disable_executor_->HasExecutor()); } TEST_F(ResourceBaseTest, DUMP) { - ASSERT_FALSE(only_loader_->Dump().empty()); - ASSERT_FALSE(only_executor_->Dump().empty()); - ASSERT_FALSE(both_enable_->Dump().empty()); - ASSERT_FALSE(both_disable_->Dump().empty()); - std::cout << *only_loader_ << *only_executor_ << *both_enable_ << *both_disable_; + ASSERT_FALSE(enable_executor_->Dump().empty()); + ASSERT_FALSE(disable_executor_->Dump().empty()); + std::cout << *enable_executor_ << *disable_executor_; } /************ ResourceAdvanceTest ************/ @@ -110,7 +85,7 @@ class ResourceAdvanceTest : public testing::Test { disk_resource_ = ResourceFactory::Create("ssd", "DISK", 0); cpu_resource_ = ResourceFactory::Create("cpu", "CPU", 0); gpu_resource_ = ResourceFactory::Create("gpu", "GPU", 0); - test_resource_ = std::make_shared("test", 0, true, true); + test_resource_ = std::make_shared("test", 0, true); resources_.push_back(disk_resource_); resources_.push_back(cpu_resource_); resources_.push_back(gpu_resource_); diff --git a/core/unittest/scheduler/test_resource_mgr.cpp b/core/unittest/scheduler/test_resource_mgr.cpp index d6495971c4..be692ca4ee 100644 --- a/core/unittest/scheduler/test_resource_mgr.cpp +++ b/core/unittest/scheduler/test_resource_mgr.cpp @@ -33,9 +33,9 @@ class ResourceMgrBaseTest : public testing::Test { SetUp() override { empty_mgr_ = std::make_shared(); mgr1_ = std::make_shared(); - disk_res = std::make_shared("disk", 0, true, false); - cpu_res = std::make_shared("cpu", 1, true, false); - gpu_res = std::make_shared("gpu", 2, true, true); + disk_res = std::make_shared("disk", 0, false); + cpu_res = std::make_shared("cpu", 1, false); + gpu_res = std::make_shared("gpu", 2, true); mgr1_->Add(ResourcePtr(disk_res)); mgr1_->Add(ResourcePtr(cpu_res)); mgr1_->Add(ResourcePtr(gpu_res)); @@ -53,20 +53,20 @@ class ResourceMgrBaseTest : public testing::Test { }; TEST_F(ResourceMgrBaseTest, ADD) { - auto resource = std::make_shared("test", 0, true, true); + auto resource = std::make_shared("test", 0, true); auto ret = empty_mgr_->Add(ResourcePtr(resource)); ASSERT_EQ(ret.lock(), resource); } TEST_F(ResourceMgrBaseTest, ADD_DISK) { - auto resource = std::make_shared("disk", 0, true, true); + auto resource = std::make_shared("disk", 0, true); auto ret = empty_mgr_->Add(ResourcePtr(resource)); ASSERT_EQ(ret.lock(), resource); } TEST_F(ResourceMgrBaseTest, CONNECT) { - auto resource1 = std::make_shared("resource1", 0, true, true); - auto resource2 = std::make_shared("resource2", 2, true, true); + auto resource1 = std::make_shared("resource1", 0, true); + auto resource2 = std::make_shared("resource2", 2, true); empty_mgr_->Add(resource1); empty_mgr_->Add(resource2); Connection io("io", 500.0); @@ -74,8 +74,8 @@ TEST_F(ResourceMgrBaseTest, CONNECT) { } TEST_F(ResourceMgrBaseTest, INVALID_CONNECT) { - auto resource1 = std::make_shared("resource1", 0, true, true); - auto resource2 = std::make_shared("resource2", 2, true, true); + auto resource1 = std::make_shared("resource1", 0, true); + auto resource2 = std::make_shared("resource2", 2, true); empty_mgr_->Add(resource1); empty_mgr_->Add(resource2); Connection io("io", 500.0); @@ -164,8 +164,8 @@ class ResourceMgrAdvanceTest : public testing::Test { void SetUp() override { mgr1_ = std::make_shared(); - disk_res = std::make_shared("disk", 0, true, false); - cpu_res = std::make_shared("cpu", 0, true, true); + disk_res = std::make_shared("disk", 0, false); + cpu_res = std::make_shared("cpu", 0, true); mgr1_->Add(ResourcePtr(disk_res)); mgr1_->Add(ResourcePtr(cpu_res)); mgr1_->Start(); diff --git a/core/unittest/scheduler/test_scheduler.cpp b/core/unittest/scheduler/test_scheduler.cpp index dba8974698..c92ac6ff7e 100644 --- a/core/unittest/scheduler/test_scheduler.cpp +++ b/core/unittest/scheduler/test_scheduler.cpp @@ -37,10 +37,10 @@ class MockVecIndex : public engine::VecIndex { const float* xt = nullptr) { } -// engine::VecIndexPtr -// Clone() override { -// return milvus::engine::VecIndexPtr(); -// } + // engine::VecIndexPtr + // Clone() override { + // return milvus::engine::VecIndexPtr(); + // } int64_t GetDeviceId() override { @@ -99,8 +99,8 @@ class SchedulerTest : public testing::Test { void SetUp() override { res_mgr_ = std::make_shared(); - ResourcePtr disk = ResourceFactory::Create("disk", "DISK", 0, true, false); - ResourcePtr cpu = ResourceFactory::Create("cpu", "CPU", 0, true, false); + ResourcePtr disk = ResourceFactory::Create("disk", "DISK", 0, false); + ResourcePtr cpu = ResourceFactory::Create("cpu", "CPU", 0, false); disk_resource_ = res_mgr_->Add(std::move(disk)); cpu_resource_ = res_mgr_->Add(std::move(cpu)); @@ -143,10 +143,10 @@ class SchedulerTest2 : public testing::Test { protected: void SetUp() override { - ResourcePtr disk = ResourceFactory::Create("disk", "DISK", 0, true, false); - ResourcePtr cpu0 = ResourceFactory::Create("cpu0", "CPU", 0, true, false); - ResourcePtr cpu1 = ResourceFactory::Create("cpu1", "CPU", 1, true, false); - ResourcePtr cpu2 = ResourceFactory::Create("cpu2", "CPU", 2, true, false); + ResourcePtr disk = ResourceFactory::Create("disk", "DISK", 0, false); + ResourcePtr cpu0 = ResourceFactory::Create("cpu0", "CPU", 0, false); + ResourcePtr cpu1 = ResourceFactory::Create("cpu1", "CPU", 1, false); + ResourcePtr cpu2 = ResourceFactory::Create("cpu2", "CPU", 2, false); res_mgr_ = std::make_shared(); disk_ = res_mgr_->Add(std::move(disk)); @@ -163,8 +163,8 @@ class SchedulerTest2 : public testing::Test { res_mgr_->Connect("cpu0", "cpu2", IO); #ifdef MILVUS_GPU_VERSION - ResourcePtr gpu0 = ResourceFactory::Create("gpu0", "GPU", 0, true, true); - ResourcePtr gpu1 = ResourceFactory::Create("gpu1", "GPU", 1, true, true); + ResourcePtr gpu0 = ResourceFactory::Create("gpu0", "GPU", 0); + ResourcePtr gpu1 = ResourceFactory::Create("gpu1", "GPU", 1); gpu_0_ = res_mgr_->Add(std::move(gpu0)); gpu_1_ = res_mgr_->Add(std::move(gpu1)); res_mgr_->Connect("cpu1", "gpu0", PCIE1); diff --git a/core/unittest/server/test_rpc.cpp b/core/unittest/server/test_rpc.cpp index e04411fad3..fa4c976e36 100644 --- a/core/unittest/server/test_rpc.cpp +++ b/core/unittest/server/test_rpc.cpp @@ -55,9 +55,9 @@ class RpcHandlerTest : public testing::Test { SetUp() override { auto res_mgr = milvus::scheduler::ResMgrInst::GetInstance(); res_mgr->Clear(); - res_mgr->Add(milvus::scheduler::ResourceFactory::Create("disk", "DISK", 0, true, false)); - res_mgr->Add(milvus::scheduler::ResourceFactory::Create("cpu", "CPU", 0, true, true)); - res_mgr->Add(milvus::scheduler::ResourceFactory::Create("gtx1660", "GPU", 0, true, true)); + res_mgr->Add(milvus::scheduler::ResourceFactory::Create("disk", "DISK", 0, false)); + res_mgr->Add(milvus::scheduler::ResourceFactory::Create("cpu", "CPU", 0)); + res_mgr->Add(milvus::scheduler::ResourceFactory::Create("gtx1660", "GPU", 0)); auto default_conn = milvus::scheduler::Connection("IO", 500.0); auto PCIE = milvus::scheduler::Connection("IO", 11000.0);