Line data Source code
1 : /**
2 : * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 :
11 : #include "comm_engine_res_aicpu_mgr.h"
12 : #include "log.h"
13 :
14 19 : CommEngineResAicpuMgr::CommEngineResAicpuMgr(
15 19 : HcclCommDfxLite& dfx, std::function<HcclResult(bool)> checkExecStatusCallback)
16 : {
17 19 : threadMgr_ = std::make_unique<ThreadAicpuMgr>(dfx, std::move(checkExecStatusCallback));
18 19 : notifyMgr_ = std::make_unique<NotifyAicpuMgr>();
19 19 : HCCL_INFO("[CommEngineResAicpuMgr][%s] constructed", __func__);
20 19 : }
21 :
22 19 : CommEngineResAicpuMgr::~CommEngineResAicpuMgr() { HCCL_INFO("[CommEngineResAicpuMgr][%s] destroyed", __func__); }
23 :
24 2 : HcclResult CommEngineResAicpuMgr::InitThreads(ThreadMgrAicpuParam* param)
25 : {
26 2 : CHK_SMART_PTR_NULL(threadMgr_);
27 2 : return threadMgr_->InitThreads(param);
28 : }
29 :
30 1 : HcclResult CommEngineResAicpuMgr::NotifyFree(NotifyMgrAicpuParam* param)
31 : {
32 1 : CHK_SMART_PTR_NULL(notifyMgr_);
33 1 : return notifyMgr_->NotifyFree(param);
34 : }
35 :
36 1 : HcclResult CommEngineResAicpuMgr::NotifyAlloc(NotifyMgrAicpuParam* param)
37 : {
38 1 : CHK_SMART_PTR_NULL(notifyMgr_);
39 1 : return notifyMgr_->NotifyAlloc(param);
40 : }
41 :
42 1 : void CommEngineResAicpuMgr::ReserveNotifyCapacity(size_t n)
43 : {
44 1 : if (notifyMgr_) {
45 1 : notifyMgr_->ReserveNotifyCapacity(n);
46 : }
47 1 : }
48 :
49 9 : const std::vector<std::shared_ptr<Thread>>& CommEngineResAicpuMgr::GetAllThread() { return threadMgr_->GetAllThread(); }
50 :
51 9 : std::shared_mutex& CommEngineResAicpuMgr::GetThreadMutex() { return threadMgr_->GetThreadMutex(); }
|