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 "hccl_alg.h"
12 : #include "topo_matcher.h"
13 :
14 : namespace hccl
15 : {
16 : constexpr u32 TINY_MEMORY_SIZE = 32; // sendBuff或recvBuff为空时, 使用的DeviceMem大小
17 :
18 0 : HcclAlg::HcclAlg(CCLBufferManager &cclBufferManager, const HcclDispatcher dispatcher, const HcclDispatcher vDispatcher) : cclBufferManager_(cclBufferManager), dispatcher_(dispatcher), vDispatcher_(vDispatcher)
19 : {
20 0 : }
21 :
22 0 : HcclAlg::~HcclAlg()
23 : {
24 0 : }
25 :
26 0 : HcclResult HcclAlg::Init(std::unique_ptr<WorkspaceResource> &workSpaceRes,
27 : const std::unique_ptr<NotifyPool> ¬ifyPool, std::map<HcclIpAddress, HcclNetDevCtx> &netDevCtxMap,
28 : const std::unique_ptr<QueueNotifyManager> &queueNotifyManager,
29 : HcclAlgoAttr &algoAttr, HcclTopoAttr &topoAttr, bool isHeterogComm)
30 : {
31 : (void) workSpaceRes;
32 : (void) notifyPool;
33 : (void) netDevCtxMap;
34 : (void) queueNotifyManager;
35 : (void) algoAttr;
36 : (void) topoAttr;
37 : (void) isHeterogComm;
38 0 : return HCCL_SUCCESS;
39 : }
40 :
41 0 : HcclResult HcclAlg::Init(HcclAlgoAttr &algoAttr, HcclTopoAttr &topoAttr, bool isHeterogComm)
42 : {
43 : (void) algoAttr;
44 : (void) topoAttr;
45 : (void) isHeterogComm;
46 0 : return HCCL_SUCCESS;
47 : }
48 :
49 0 : HcclResult HcclAlg::GetAlltoAllStagedWorkSpaceMemSize(
50 : std::vector<SendRecvInfo> &allMeshAggregationSendRecvInfo, u64 &memSize)
51 : {
52 : (void) allMeshAggregationSendRecvInfo;
53 : (void) memSize;
54 0 : return HCCL_SUCCESS;
55 : }
56 :
57 0 : HcclResult HcclAlg::GetAllReduceScratchSize(const u64 count, const HcclDataType dataType, u64 &scratchSize)
58 : {
59 : (void) count;
60 : (void) dataType;
61 : (void) scratchSize;
62 0 : return HCCL_SUCCESS;
63 : }
64 :
65 0 : HcclResult HcclAlg::GetTopoType(TopoType &topoType)
66 : {
67 : (void) topoType;
68 0 : return HCCL_SUCCESS;
69 : }
70 :
71 0 : HcclResult HcclAlg::SetAlgType(AlgType algType, HcclCMDType opType)
72 : {
73 : (void) algType;
74 : (void) opType;
75 0 : return HCCL_SUCCESS;
76 : }
77 :
78 0 : HcclResult HcclAlg::GetAlgType(AlgType &algType, HcclCMDType opType)
79 : {
80 : (void) algType;
81 : (void) opType;
82 0 : return HCCL_SUCCESS;
83 : }
84 :
85 0 : HcclResult HcclAlg::SupportDeterministicOptim(bool &isDeterministicOptim)
86 : {
87 : (void) isDeterministicOptim;
88 0 : return HCCL_SUCCESS;
89 : }
90 :
91 0 : u8 HcclAlg::GetDeterministicConfig() const
92 : {
93 0 : return 0;
94 : }
95 :
96 0 : HcclResult HcclAlg::SetDeterministicConfig(const u8 deterministic)
97 : {
98 : (void) deterministic;
99 0 : return HCCL_SUCCESS;
100 : }
101 :
102 0 : HcclResult HcclAlg::SetAivModeConfig(const bool aivMode)
103 : {
104 : (void) aivMode;
105 0 : return HCCL_SUCCESS;
106 : }
107 :
108 0 : HcclResult HcclAlg::SetOnlyAivModeConfig(const bool isOnlyAiv)
109 : {
110 : (void) isOnlyAiv;
111 0 : return HCCL_SUCCESS;
112 : }
113 :
114 0 : bool HcclAlg::GetAicpuUnfoldConfig() const
115 : {
116 0 : return false;
117 : }
118 :
119 0 : HcclResult HcclAlg::SetAicpuUnfoldConfig(const bool aicpuUnfold)
120 : {
121 : (void) aicpuUnfold;
122 0 : return HCCL_SUCCESS;
123 : }
124 :
125 0 : HcclResult HcclAlg::SetExecTimeOutConfig(const s32 execTimeOut)
126 : {
127 : (void) execTimeOut;
128 0 : return HCCL_SUCCESS;
129 : }
130 :
131 0 : HcclResult HcclAlg::SetAlgoConfig(const std::map<HcclCMDType, std::vector<HcclAlgoType>>& algoMap)
132 : {
133 : (void) algoMap;
134 0 : return HCCL_SUCCESS;
135 : }
136 :
137 0 : HcclResult HcclAlg::GetRankVecInfo(std::vector<std::vector<std::vector<u32>>> &serverAndsuperPodToRank)
138 : {
139 : (void) serverAndsuperPodToRank;
140 0 : return HCCL_SUCCESS;
141 : }
142 :
143 0 : HcclResult HcclAlg::GetIsBridgeVector(std::vector<bool> &isBridgeVector)
144 : {
145 : (void) isBridgeVector;
146 0 : return HCCL_SUCCESS;
147 : }
148 0 : HcclResult HcclAlg::GetCommPlaneRanks(std::vector<std::vector<std::vector<u32>>> &commPlaneRanks)
149 : {
150 : (void) commPlaneRanks;
151 0 : return HCCL_SUCCESS;
152 : }
153 :
154 0 : void HcclAlg::GetCommPlaneVector(std::vector<std::vector<std::vector<RankInfo>>> &commPlaneVector)
155 : {
156 : (void) commPlaneVector;
157 0 : }
158 :
159 0 : HcclResult HcclAlg::GetCommPlaneSubGroupVector(std::vector<std::vector<std::vector<std::vector<u32>>>> &commPlaneSubGroupVector)
160 : {
161 : (void) commPlaneSubGroupVector;
162 0 : return HCCL_SUCCESS;
163 : }
164 :
165 0 : HcclResult HcclAlg::GetAHCAlgOption(std::map<AHCConcOpType, TemplateType> &ahcAlgOption)
166 : {
167 : (void) ahcAlgOption;
168 0 : return HCCL_SUCCESS;
169 : }
170 :
171 0 : HcclResult HcclAlg::GetIsUsedRdmaMap(std::unordered_map<u32, bool> &isUsedRdmaMap)
172 : {
173 : (void) isUsedRdmaMap;
174 0 : return HCCL_SUCCESS;
175 : }
176 :
177 0 : HcclResult HcclAlg::GetTinyMem(DeviceMem &tinySendRecvMem)
178 : {
179 : (void) tinySendRecvMem;
180 0 : return HCCL_SUCCESS;
181 : }
182 :
183 0 : HcclResult HcclAlg::InitExternalEnable(HcclExternalEnable &externalEnable)
184 : {
185 : (void) externalEnable;
186 0 : return HCCL_SUCCESS;
187 : }
188 :
189 0 : HcclResult HcclAlg::InitTopoInfo(HcclTopoInfo &topoInfo, HcclTopoAttr &topoAttr)
190 : {
191 : (void) topoInfo;
192 : (void) topoAttr;
193 0 : return HCCL_SUCCESS;
194 : }
195 :
196 0 : HcclResult HcclAlg::InitAlgoInfo(HcclAlgoInfo &algoInfo, HcclAlgoAttr &algoAttr)
197 : {
198 : (void) algoInfo;
199 : (void) algoAttr;
200 0 : return HCCL_SUCCESS;
201 : }
202 :
203 : #ifndef OPEN_HCCL_TEST
204 : // 上层保证,以下方法在初始化成功后才会调用,所以未对pimpl_进行保护判断
205 : HcclResult HcclAlg::ReleaseCommInfos()
206 : {
207 : return HCCL_SUCCESS;
208 : }
209 :
210 : HcclResult HcclAlg::ClearOpResource(const std::string &tag)
211 : {
212 : (void) tag;
213 : return HCCL_SUCCESS;
214 : }
215 :
216 : HcclResult HcclAlg::CreateMutiStreamRes(const std::string &tag, Stream &stream, level1StreamInfo_t &streamInfo,
217 : AlgType algType, bool isAicpuModeEn)
218 : {
219 : (void) tag;
220 : (void) stream;
221 : (void) streamInfo;
222 : (void) algType;
223 : (void) isAicpuModeEn;
224 : return HCCL_SUCCESS;
225 : }
226 :
227 : HcclResult HcclAlg::CreateComm(const std::string &tag, DeviceMem &inputMem, DeviceMem &outputMem, AlgType algType,
228 : std::unique_ptr<CommInfo> &commInfo, u32 root, bool isP2p, bool isAicpuModeEn)
229 : {
230 : (void) tag;
231 : (void) inputMem;
232 : (void) outputMem;
233 : (void) algType;
234 : (void) commInfo;
235 : (void) root;
236 : (void) isP2p;
237 : (void) isAicpuModeEn;
238 : return HCCL_SUCCESS;
239 : }
240 :
241 : HcclResult HcclAlg::CreateComm(
242 : const std::string &tag, DeviceMem &inputMem, DeviceMem &outputMem, AlgType algType, u32 root, bool isP2p)
243 : {
244 : (void) tag;
245 : (void) inputMem;
246 : (void) outputMem;
247 : (void) algType;
248 : (void) root;
249 : (void) isP2p;
250 : return HCCL_SUCCESS;
251 : }
252 :
253 : void HcclAlg::CancelCommRes(const std::string &tag)
254 : {
255 : (void) tag;
256 : }
257 :
258 : void HcclAlg::Break()
259 : {
260 : }
261 :
262 : HcclResult HcclAlg::SetHDCModeInfo(
263 : std::unordered_map<std::string, std::map<u32, HcclIpAddress>> &rankDevicePhyIdNicInfoMap,
264 : std::vector<u32> &ranksPort, std::vector<u32> &vnicRanksPort, bool isSetHDCModeInfo, bool isUseRankPort)
265 : {
266 : (void) rankDevicePhyIdNicInfoMap;
267 : (void) ranksPort;
268 : (void) vnicRanksPort;
269 : (void) isSetHDCModeInfo;
270 : (void) isUseRankPort;
271 : return HCCL_SUCCESS;
272 : }
273 : #endif
274 : }
|