1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FFRT_EXECUTE_UNIT_HPP 17 #define FFRT_EXECUTE_UNIT_HPP 18 19 20 #include "sched/workgroup_internal.h" 21 #include "eu/worker_manager.h" 22 #include "eu/thread_group.h" 23 #include "core/task_ctx.h" 24 25 namespace ffrt { 26 class ExecuteUnit { 27 public: Instance()28 static ExecuteUnit& Instance() 29 { 30 static ExecuteUnit eu; 31 return eu; 32 } 33 34 ThreadGroup* BindTG(const DevType dev, QoS& qos); 35 void UnbindTG(const DevType dev, QoS& qos); 36 void BindWG(const DevType dev, QoS& qos); 37 NotifyTaskAdded(const QoS & qos)38 void NotifyTaskAdded(const QoS& qos) 39 { 40 { 41 wManager[static_cast<size_t>(DevType::CPU)]->NotifyTaskAdded(qos); 42 } 43 } 44 GetSleepCtl(int qos)45 std::mutex* GetSleepCtl(int qos) 46 { 47 return wManager[static_cast<size_t>(DevType::CPU)]->GetSleepCtl(qos); 48 } 49 GetGroupCtl()50 WorkerGroupCtl* GetGroupCtl() 51 { 52 return wManager[static_cast<size_t>(DevType::CPU)]->GetGroupCtl(); 53 } 54 55 private: 56 ExecuteUnit(); 57 58 std::array<std::unique_ptr<WorkerManager>, static_cast<size_t>(DevType::DEVMAX)> wManager; 59 }; 60 } // namespace ffrt 61 #endif 62