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_executor_base.h"
12 : #include "hccl_aiv.h"
13 :
14 : namespace hccl {
15 :
16 181 : CollExecutorBase::CollExecutorBase(const HcclDispatcher dispatcher, std::unique_ptr<TopoMatcher>& topoMatcher)
17 181 : : dispatcher_(dispatcher),
18 181 : topoMatcher_(topoMatcher)
19 160 : {}
20 :
21 94 : HcclResult CollExecutorBase::SetAlgType(const AlgType algType)
22 : {
23 94 : const std::vector<AlgTypeLevel0>& l0Algo = desc_.level0SupportedAlgos;
24 94 : const std::vector<AlgTypeLevel1>& l1Algo = desc_.level1SupportedAlgos;
25 94 : const std::vector<AlgTypeLevel2>& l2Algo = desc_.level2SupportedAlgos;
26 :
27 94 : algType_ = algType;
28 94 : if (!l0Algo.empty() && std::find(l0Algo.begin(), l0Algo.end(), algType_.algoLevel0) == l0Algo.end()) {
29 0 : HCCL_WARNING("[%s] not support level0 algo[%d], reset to algo[%d]", __func__, algType_.algoLevel0, l0Algo[0]);
30 0 : algType_.algoLevel0 = l0Algo[0];
31 : }
32 92 : if (!l1Algo.empty() && std::find(l1Algo.begin(), l1Algo.end(), algType_.algoLevel1) == l1Algo.end()) {
33 0 : HCCL_WARNING("[%s] not support level1 algo[%d], reset to algo[%d]", __func__, algType_.algoLevel1, l1Algo[0]);
34 0 : algType_.algoLevel1 = l1Algo[0];
35 : }
36 92 : if (!l2Algo.empty() && std::find(l2Algo.begin(), l2Algo.end(), algType_.algoLevel2) == l2Algo.end()) {
37 1 : HCCL_WARNING("[%s] not support level2 algo[%d], reset to algo[%d]", __func__, algType_.algoLevel2, l2Algo[0]);
38 1 : algType_.algoLevel2 = l2Algo[0];
39 : }
40 : // 记录刷新后的算法类型到executor的描述中
41 90 : desc_.algType = algType_;
42 90 : return HCCL_SUCCESS;
43 : }
44 :
45 70 : HcclResult CollExecutorBase::SetCCLInBuffer(u64 cclbufferSize)
46 : {
47 70 : inCCLbufferSize_ = cclbufferSize;
48 70 : return HCCL_SUCCESS;
49 : }
50 :
51 33 : HcclResult CollExecutorBase::SetIsSupportSDMAReduce(bool isSupportSDMAReduce)
52 : {
53 33 : isSupportSDMAReduce_ = isSupportSDMAReduce;
54 33 : return HCCL_SUCCESS;
55 : }
56 :
57 0 : HcclResult CollExecutorBase::RunTemplate(const std::unique_ptr<AlgTemplateBase>& tempAlg, const SubCommInfo& commInfo)
58 : {
59 0 : HcclResult ret = tempAlg->RunAsync(commInfo.localRank, commInfo.localRankSize, commInfo.links);
60 0 : CHK_PRT_RET(
61 : ret == HCCL_E_AGAIN,
62 : HCCL_WARNING("[CollExecutorBase][RunTemplate]"
63 : "group has been destroyed. Break!"),
64 : ret);
65 0 : CHK_PRT_RET(
66 : ret != HCCL_SUCCESS,
67 : HCCL_ERROR(
68 : "[CollExecutorBase][RunTemplate]run tempAlg rank[%u] rank size[%u] failed", commInfo.localRank,
69 : commInfo.localRankSize),
70 : ret);
71 0 : return HCCL_SUCCESS;
72 : }
73 :
74 : HcclResult
75 1 : CollExecutorBase::GetAivExecParam(const OpParam& param, AlgResourceResponse& algRes, AivSuperKernelArgs& args)
76 : {
77 1 : return HCCL_SUCCESS;
78 : }
79 :
80 25 : HcclResult CollExecutorBase::PrepareCommInfoToDevice(AlgResourceResponse& algResource)
81 : {
82 : (void)algResource;
83 25 : return HCCL_SUCCESS;
84 : }
85 :
86 0 : HcclResult CollExecutorBase::SetRmaInfo(void* rmaInfo)
87 : {
88 0 : CHK_PTR_NULL(rmaInfo);
89 0 : rmaInfo_ = rmaInfo;
90 0 : return HCCL_SUCCESS;
91 : }
92 :
93 0 : HcclResult CollExecutorBase::CalcIncreLinkRequest(
94 : const OpParam& param, std::set<u32>& ranksLinked, AlgResourceRequest& resourceRequest, bool& needIncreLink)
95 : {
96 : (void)ranksLinked;
97 : (void)needIncreLink;
98 0 : return HCCL_SUCCESS;
99 : }
100 :
101 0 : HcclResult CollExecutorBase::CreatePairWiseList(HcclSendRecvItem* sendRecvInfo, u32 itemNum) { return HCCL_SUCCESS; }
102 :
103 0 : HcclResult CollExecutorBase::GetPairWiseList(std::vector<std::vector<HcclSendRecvItem*>>& sendRecvPairList)
104 : {
105 0 : return HCCL_SUCCESS;
106 : }
107 :
108 24 : HcclResult CollExecutorBase::SetAlgOpContext(AlgOpContext algOpContext)
109 : {
110 24 : algOpContext_ = algOpContext;
111 24 : return HCCL_SUCCESS;
112 : }
113 :
114 24 : HcclResult CollExecutorBase::SetAivClearEnable(bool aivClearEnable)
115 : {
116 24 : aivClearEnable_ = aivClearEnable;
117 24 : return HCCL_SUCCESS;
118 : }
119 :
120 1 : HcclResult CollExecutorBase::CalNumBlocks(u32& numBlocks, u32 rankSize, u64 dataSize, HcclCMDType cmdType)
121 : {
122 1 : numBlocks = rankSize;
123 1 : return HCCL_SUCCESS;
124 : }
125 :
126 21 : HcclResult CollExecutorBase::GetNumBlocks(u32& numBlocks) const
127 : {
128 21 : numBlocks = numBlocks_;
129 21 : return HCCL_SUCCESS;
130 : }
131 :
132 6 : HcclResult CollExecutorBase::SetNumBlocks(const u32& numBlocks)
133 : {
134 6 : numBlocks_ = numBlocks;
135 6 : return HCCL_SUCCESS;
136 : }
137 :
138 2 : HcclResult CollExecutorBase::GetCache(HcclCacheInfo& cacheInfo)
139 : {
140 2 : cacheInfo = cacheInfo_;
141 2 : return HCCL_SUCCESS;
142 : }
143 :
144 24 : HcclResult CollExecutorBase::SetOpCounter(const OpCounterInfo& opCounter)
145 : {
146 24 : opCounter_ = opCounter;
147 24 : return HCCL_SUCCESS;
148 : }
149 0 : HcclResult CollExecutorBase::GetAdjInfo(AlgResourceResponse& algRes, AdjInfo& adjInfo)
150 : {
151 : (void)adjInfo;
152 0 : return HCCL_SUCCESS;
153 : }
154 :
155 0 : HcclResult CollExecutorBase::MarkNeedAlltoallvCache()
156 : {
157 0 : HCCL_ERROR("[CollExecutorBase][MarkNeedAlltoallvCache] not supported for current executor!");
158 0 : return HCCL_E_NOT_SUPPORT;
159 : }
160 :
161 0 : HcclResult CollExecutorBase::GetHcclOffsetDstRanksMap(
162 : std::unordered_map<uint64_t, std::vector<uint32_t>>& hcclOffsetDstRanksMap) const
163 : {
164 : UNUSED_PARAM(hcclOffsetDstRanksMap);
165 0 : HCCL_ERROR("[CollExecutorBase][GetHcclOffsetDstRanksMap] not supported for current executor!");
166 0 : return HCCL_E_NOT_SUPPORT;
167 : }
168 :
169 0 : void CollExecutorBase::SetWorkflowMode(HcclWorkflowMode workflowMode)
170 : {
171 : UNUSED_PARAM(workflowMode);
172 0 : HCCL_DEBUG("[CollExecutorBase][SetWorkflowMode] base class default, no effect");
173 0 : }
174 :
175 0 : HcclWorkflowMode CollExecutorBase::GetExecutorWorkflowMode() const
176 : {
177 0 : HCCL_ERROR("[CollExecutorBase][GetExecutorWorkflowMode] base class should not be called");
178 0 : return HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE;
179 : }
180 :
181 : } // namespace hccl
|