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 171 : {}
20 :
21 98 : HcclResult CollExecutorBase::SetAlgType(const AlgType algType)
22 : {
23 98 : const std::vector<AlgTypeLevel0>& l0Algo = desc_.level0SupportedAlgos;
24 98 : const std::vector<AlgTypeLevel1>& l1Algo = desc_.level1SupportedAlgos;
25 98 : const std::vector<AlgTypeLevel2>& l2Algo = desc_.level2SupportedAlgos;
26 :
27 98 : algType_ = algType;
28 98 : 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 95 : 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 97 : 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 96 : desc_.algType = algType_;
42 95 : return HCCL_SUCCESS;
43 : }
44 :
45 77 : HcclResult CollExecutorBase::SetCCLInBuffer(u64 cclbufferSize)
46 : {
47 77 : inCCLbufferSize_ = cclbufferSize;
48 77 : return HCCL_SUCCESS;
49 : }
50 :
51 34 : HcclResult CollExecutorBase::SetIsSupportSDMAReduce(bool isSupportSDMAReduce)
52 : {
53 34 : isSupportSDMAReduce_ = isSupportSDMAReduce;
54 34 : 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 1 : HcclResult CollExecutorBase::GetAivExecParam(
75 : [[maybe_unused]] const OpParam& param, [[maybe_unused]] AlgResourceResponse& algRes,
76 : [[maybe_unused]] AivSuperKernelArgs& args)
77 : {
78 1 : return HCCL_SUCCESS;
79 : }
80 :
81 25 : HcclResult CollExecutorBase::PrepareCommInfoToDevice(AlgResourceResponse& algResource)
82 : {
83 : (void)algResource;
84 25 : return HCCL_SUCCESS;
85 : }
86 :
87 0 : HcclResult CollExecutorBase::SetRmaInfo(void* rmaInfo)
88 : {
89 0 : CHK_PTR_NULL(rmaInfo);
90 0 : rmaInfo_ = rmaInfo;
91 0 : return HCCL_SUCCESS;
92 : }
93 :
94 0 : HcclResult CollExecutorBase::CalcIncreLinkRequest(
95 : [[maybe_unused]] const OpParam& param, std::set<u32>& ranksLinked,
96 : [[maybe_unused]] AlgResourceRequest& resourceRequest, bool& needIncreLink)
97 : {
98 : (void)ranksLinked;
99 : (void)needIncreLink;
100 0 : return HCCL_SUCCESS;
101 : }
102 :
103 : HcclResult
104 0 : CollExecutorBase::CreatePairWiseList([[maybe_unused]] HcclSendRecvItem* sendRecvInfo, [[maybe_unused]] u32 itemNum)
105 : {
106 0 : return HCCL_SUCCESS;
107 : }
108 :
109 : HcclResult
110 0 : CollExecutorBase::GetPairWiseList([[maybe_unused]] std::vector<std::vector<HcclSendRecvItem*>>& sendRecvPairList)
111 : {
112 0 : return HCCL_SUCCESS;
113 : }
114 :
115 : HcclResult
116 0 : CollExecutorBase::GetPairWiseList([[maybe_unused]] HcclSendRecvItem* sendRecvInfo, [[maybe_unused]] u32 itemNum)
117 : {
118 0 : return HCCL_SUCCESS;
119 : }
120 :
121 24 : HcclResult CollExecutorBase::SetAlgOpContext(AlgOpContext algOpContext)
122 : {
123 24 : algOpContext_ = algOpContext;
124 24 : return HCCL_SUCCESS;
125 : }
126 :
127 24 : HcclResult CollExecutorBase::SetAivClearEnable(bool aivClearEnable)
128 : {
129 24 : aivClearEnable_ = aivClearEnable;
130 24 : return HCCL_SUCCESS;
131 : }
132 :
133 1 : HcclResult CollExecutorBase::CalNumBlocks(
134 : u32& numBlocks, u32 rankSize, [[maybe_unused]] u64 dataSize, [[maybe_unused]] HcclCMDType cmdType)
135 : {
136 1 : numBlocks = rankSize;
137 1 : return HCCL_SUCCESS;
138 : }
139 :
140 21 : HcclResult CollExecutorBase::GetNumBlocks(u32& numBlocks) const
141 : {
142 21 : numBlocks = numBlocks_;
143 21 : return HCCL_SUCCESS;
144 : }
145 :
146 6 : HcclResult CollExecutorBase::SetNumBlocks(const u32& numBlocks)
147 : {
148 6 : numBlocks_ = numBlocks;
149 6 : return HCCL_SUCCESS;
150 : }
151 :
152 2 : HcclResult CollExecutorBase::GetCache(HcclCacheInfo& cacheInfo)
153 : {
154 2 : cacheInfo = cacheInfo_;
155 2 : return HCCL_SUCCESS;
156 : }
157 :
158 24 : HcclResult CollExecutorBase::SetOpCounter(const OpCounterInfo& opCounter)
159 : {
160 24 : opCounter_ = opCounter;
161 24 : return HCCL_SUCCESS;
162 : }
163 0 : HcclResult CollExecutorBase::GetAdjInfo([[maybe_unused]] AlgResourceResponse& algRes, AdjInfo& adjInfo)
164 : {
165 : (void)adjInfo;
166 0 : return HCCL_SUCCESS;
167 : }
168 :
169 0 : HcclResult CollExecutorBase::MarkNeedAlltoallvCache()
170 : {
171 0 : HCCL_ERROR("[CollExecutorBase][MarkNeedAlltoallvCache] not supported for current executor!");
172 0 : return HCCL_E_NOT_SUPPORT;
173 : }
174 :
175 0 : HcclResult CollExecutorBase::GetHcclOffsetDstRanksMap(
176 : std::unordered_map<uint64_t, std::vector<uint32_t>>& hcclOffsetDstRanksMap) const
177 : {
178 : UNUSED_PARAM(hcclOffsetDstRanksMap);
179 0 : HCCL_ERROR("[CollExecutorBase][GetHcclOffsetDstRanksMap] not supported for current executor!");
180 0 : return HCCL_E_NOT_SUPPORT;
181 : }
182 :
183 0 : void CollExecutorBase::SetWorkflowMode(HcclWorkflowMode workflowMode)
184 : {
185 : UNUSED_PARAM(workflowMode);
186 0 : HCCL_DEBUG("[CollExecutorBase][SetWorkflowMode] base class default, no effect");
187 0 : }
188 :
189 0 : HcclWorkflowMode CollExecutorBase::GetExecutorWorkflowMode() const
190 : {
191 0 : HCCL_ERROR("[CollExecutorBase][GetExecutorWorkflowMode] base class should not be called");
192 0 : return HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE;
193 : }
194 :
195 : } // namespace hccl
|