1 /** 2 * Copyright 2022 Huawei Technologies Co., Ltd 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef MINDSPORE_LITE_SRC_RUNTIME_THREAD_POOL_MANAGER_H_ 18 #define MINDSPORE_LITE_SRC_RUNTIME_THREAD_POOL_MANAGER_H_ 19 20 #include <map> 21 #include <string> 22 #include <vector> 23 #include "thread/threadpool.h" 24 25 namespace mindspore { 26 namespace lite { 27 class ThreadPoolReuseManager { 28 public: GetInstance()29 static ThreadPoolReuseManager *GetInstance() { 30 static ThreadPoolReuseManager instance; 31 return &instance; 32 } 33 34 ~ThreadPoolReuseManager(); 35 36 ThreadPool *GetThreadPool(size_t actor_num, size_t inter_op_parallel_num, size_t thread_num, BindMode bind_mode, 37 const std::vector<int> &core_list, std::string runner_id); 38 39 void RetrieveThreadPool(size_t actor_num, size_t inter_op_parallel_num, size_t thread_num, BindMode bind_mode, 40 const std::vector<int> &core_list, ThreadPool *thread_pool); 41 42 private: 43 ThreadPoolReuseManager() = default; 44 45 std::string ComputeHash(size_t actor_num, size_t inter_op_parallel_num, size_t thread_num, BindMode bind_mode, 46 const std::vector<int> &core_list); 47 48 std::map<std::string, std::vector<ThreadPool *>> thread_pool_container_; 49 }; 50 } // namespace lite 51 } // namespace mindspore 52 #endif // MINDSPORE_LITE_SRC_RUNTIME_THREAD_POOL_MANAGER_H_ 53