Line data Source code
1 : /**
2 : * Copyright (c) 2025 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 "coll_comm_aicpu_mgr.h"
12 :
13 6 : HcclResult CollCommAicpuMgr::AcquireCollCommAicpu()
14 : {
15 6 : if (collCommAicpu_ != nullptr) {
16 0 : HCCL_DEBUG("collCommAicpu_ is not nullptr, no need acquire.");
17 0 : return HCCL_SUCCESS;
18 : }
19 :
20 6 : EXCEPTION_CATCH(collCommAicpu_ = std::make_unique<CollCommAicpu>(), return HCCL_E_INTERNAL);
21 6 : return HCCL_SUCCESS;
22 : }
23 :
24 0 : HcclResult CollCommAicpuMgr::InitAicpuIndOp(CommAicpuParam *commAicpuParam)
25 : {
26 0 : CHK_PTR_NULL(collCommAicpu_);
27 0 : return collCommAicpu_->InitAicpuIndOp(commAicpuParam);
28 : }
29 :
30 1 : HcclResult CollCommAicpuMgr::InitThreads(ThreadMgrAicpuParam *param)
31 : {
32 1 : CHK_PTR_NULL(collCommAicpu_);
33 1 : return collCommAicpu_->InitThreads(param);
34 : }
35 :
36 0 : HcclResult CollCommAicpuMgr::AllocChannelResource(HcclChannelUrmaRes *commParam)
37 : {
38 0 : CHK_PTR_NULL(collCommAicpu_);
39 0 : return collCommAicpu_->AllocChannelResource(commParam);
40 : }
41 :
42 0 : HcclResult CollCommAicpuMgr::UpdateChannelResource(HcclChannelUrmaRes *commParam)
43 : {
44 0 : CHK_PTR_NULL(collCommAicpu_);
45 0 : return collCommAicpu_->Resume(commParam);
46 : }
47 :
48 0 : HcclResult CollCommAicpuMgr::NotifyFree(NotifyMgrAicpuParam *param)
49 : {
50 0 : CHK_PTR_NULL(collCommAicpu_);
51 0 : return collCommAicpu_->NotifyFree(param);
52 : }
53 :
54 0 : HcclResult CollCommAicpuMgr::NotifyAlloc(NotifyMgrAicpuParam *param)
55 : {
56 0 : CHK_PTR_NULL(collCommAicpu_);
57 0 : return collCommAicpu_->NotifyAlloc(param);
58 : }
59 :
60 5 : bool CollCommAicpuMgr::IsUsed()
61 : {
62 5 : std::shared_lock<std::shared_mutex> rwlock(isUsedMutex_);
63 5 : return isUsed_;
64 5 : }
65 :
66 2 : void CollCommAicpuMgr::SetUsed(bool used)
67 : {
68 2 : std::unique_lock<std::shared_mutex> rwlock(isUsedMutex_);
69 2 : isUsed_ = used;
70 2 : }
71 :
72 0 : void CollCommAicpuMgr::SetOldA5Comm(void *oldA5Comm)
73 : {
74 0 : if (oldA5Comm_ == nullptr) {
75 0 : oldA5Comm_ = oldA5Comm;
76 : }
77 0 : }
|