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