From a043de2f5cc29ff46fd34b164a3d21fb7e200bff Mon Sep 17 00:00:00 2001 From: starlord Date: Mon, 14 Oct 2019 14:28:17 +0800 Subject: [PATCH 1/2] add tbb so Former-commit-id: c8f3f3a6d888e64eec17b5b3a38a09682ea16def From 0f58d2da738b118d3c1f68722b7915b32aa92930 Mon Sep 17 00:00:00 2001 From: starlord Date: Mon, 14 Oct 2019 14:29:53 +0800 Subject: [PATCH 2/2] remove unused files Former-commit-id: 3d196d97985b876d064a806fdc0c539c494aa55a --- cpp/src/scheduler/BuildMgr.cpp | 22 ------ cpp/src/scheduler/BuildMgr.h | 63 ---------------- cpp/src/scheduler/optimizer/LargeSQ8HPass.cpp | 73 ------------------- cpp/src/scheduler/optimizer/LargeSQ8HPass.h | 47 ------------ 4 files changed, 205 deletions(-) delete mode 100644 cpp/src/scheduler/BuildMgr.cpp delete mode 100644 cpp/src/scheduler/BuildMgr.h delete mode 100644 cpp/src/scheduler/optimizer/LargeSQ8HPass.cpp delete mode 100644 cpp/src/scheduler/optimizer/LargeSQ8HPass.h diff --git a/cpp/src/scheduler/BuildMgr.cpp b/cpp/src/scheduler/BuildMgr.cpp deleted file mode 100644 index d90a074d30..0000000000 --- a/cpp/src/scheduler/BuildMgr.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// 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 -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -#include "scheduler/BuildMgr.h" - -namespace milvus { -namespace scheduler {} // namespace scheduler -} // namespace milvus diff --git a/cpp/src/scheduler/BuildMgr.h b/cpp/src/scheduler/BuildMgr.h deleted file mode 100644 index ee7ab38e25..0000000000 --- a/cpp/src/scheduler/BuildMgr.h +++ /dev/null @@ -1,63 +0,0 @@ -// 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 -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// 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 - -namespace milvus { -namespace scheduler { - -class BuildMgr { - public: - explicit BuildMgr(int64_t numoftasks) : numoftasks_(numoftasks) { - } - - public: - void - Put() { - ++numoftasks_; - } - - void - take() { - --numoftasks_; - } - - int64_t - numoftasks() { - return (int64_t)numoftasks_; - } - - private: - std::atomic_long numoftasks_; -}; - -using BuildMgrPtr = std::shared_ptr; - -} // namespace scheduler -} // namespace milvus diff --git a/cpp/src/scheduler/optimizer/LargeSQ8HPass.cpp b/cpp/src/scheduler/optimizer/LargeSQ8HPass.cpp deleted file mode 100644 index 62d0e57902..0000000000 --- a/cpp/src/scheduler/optimizer/LargeSQ8HPass.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// 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 -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// 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 diff --git a/cpp/src/scheduler/optimizer/LargeSQ8HPass.h b/cpp/src/scheduler/optimizer/LargeSQ8HPass.h deleted file mode 100644 index 49e658002f..0000000000 --- a/cpp/src/scheduler/optimizer/LargeSQ8HPass.h +++ /dev/null @@ -1,47 +0,0 @@ -// 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 -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// 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