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_all_to_all_v_direct_fullmesh_executor.h"
12 :
13 : namespace hccl {
14 :
15 0 : CollRunAlltoAllDirectFullmesh::CollRunAlltoAllDirectFullmesh(
16 0 : const HcclDispatcher dispatcher, std::unique_ptr<TopoMatcher>& topoMatcher)
17 0 : : CollAlltoAllExecutor(dispatcher, topoMatcher)
18 0 : {}
19 :
20 0 : HcclResult CollRunAlltoAllDirectFullmesh::Orchestrate(OpParam& param, AlgResourceResponse& algRes)
21 : {
22 0 : HcclUs startut = TIME_NOW();
23 0 : HcclResult ret = HCCL_SUCCESS;
24 0 : tag_ = param.tag;
25 0 : algResResp_ = &algRes;
26 0 : AlltoAllVParam_ = param;
27 :
28 0 : ExecMem execMem;
29 0 : execMem.count = 0;
30 0 : execMem.inputPtr = param.inputPtr;
31 0 : execMem.outputPtr = param.outputPtr;
32 0 : execMem.inputMem = algRes.cclInputMem;
33 0 : execMem.outputMem = algRes.cclOutputMem;
34 0 : ret = KernelRun(param, execMem);
35 :
36 0 : CHK_PRT_RET(
37 : ret != HCCL_SUCCESS,
38 : HCCL_ERROR(
39 : "[CollRunAlltoAllDirectFullmesh][Orchestrate]errNo[0x%016llx]executor run failed", HCCL_ERROR_CODE(ret)),
40 : ret);
41 :
42 : // Enforce task launch at the end of Orchestrate
43 : // 注意: 不要删除这里的强制launch, 否则会导致aicpu cache功能问题
44 0 : HCCL_INFO("%s: enforce task launch at the end of Orchestrate", __func__);
45 0 : CHK_RET(LaunchTaskExtend(dispatcher_, param.stream, algResResp_->slaveStreams));
46 :
47 0 : HCCL_INFO(
48 : "tag[%s], AlltoAllDirectFullmesh tempAlg orchestrate success, take time [%lld]us.", param.tag.c_str(),
49 : DURATION_US(TIME_NOW() - startut));
50 0 : return HCCL_SUCCESS;
51 0 : }
52 :
53 0 : HcclResult CollRunAlltoAllDirectFullmesh::GetAdjInfo(AlgResourceResponse& algRes, AdjInfo& adjInfo)
54 : {
55 0 : HCCL_INFO("[GetAdjInfo-nslbdp] GetAdjInfo.");
56 0 : algResResp_ = &algRes;
57 0 : SubCommInfo levelCommInfo = {};
58 0 : AdjInfo nslbAdjInfo = {};
59 0 : u32 devNumInlocalPod = INVALID_VALUE_RANKSIZE;
60 :
61 0 : u32 localRank = topoAttr_.userRank;
62 0 : u32 localRankSize = topoAttr_.userRankSize;
63 :
64 0 : std::unique_ptr<AlgTemplateBase> levelTempAlg;
65 :
66 0 : HCCL_INFO("[GetAdjInfo-nslbdp] SelectTempAlg.");
67 0 : levelTempAlg = AlgTemplateRegistry::Instance().GetAlgTemplate(
68 0 : TemplateType::TEMPLATE_ALL_2_ALL_V_DIRECT_FULL_MESH, dispatcher_);
69 0 : CHK_SMART_PTR_NULL(levelTempAlg);
70 0 : u32 rankIdxInPod = INVALID_VALUE_RANKID;
71 0 : CHK_RET(GetLocalSDMAGroupInfo(topoAttr_.userRank, devNumInlocalPod, rankIdxInPod));
72 :
73 0 : if (devNumInlocalPod == INVALID_VALUE_RANKSIZE) {
74 0 : HCCL_INFO("[GetAdjInfo-nslbdp] devNumInlocalPod == INVALID_VALUE_RANKSIZE.");
75 0 : return HCCL_SUCCESS;
76 : }
77 :
78 0 : nslbAdjInfo.dstRankNum = devNumInlocalPod;
79 0 : CHK_RET(levelTempAlg->GetNslbAdjInfo(localRank, localRankSize, levelCommInfo.links, nslbAdjInfo));
80 :
81 0 : adjInfo.dstRankNum = nslbAdjInfo.dstRankNum;
82 0 : HCCL_INFO("[GetAdjInfo-nslbdp] adjInfo.dstRankNum[%u].", adjInfo.dstRankNum);
83 :
84 0 : for (size_t i = 0; i < nslbAdjInfo.nsAdjInfo.size(); i++) {
85 0 : NslbDpAdjInfo dpAdjInfo = {};
86 0 : dpAdjInfo.dstLocalRankId = nslbAdjInfo.nsAdjInfo[i].dstLocalRankId;
87 0 : dpAdjInfo.phaseId = nslbAdjInfo.nsAdjInfo[i].phaseId;
88 0 : dpAdjInfo.rev = 0;
89 0 : adjInfo.nsAdjInfo.push_back(dpAdjInfo);
90 0 : HCCL_INFO(
91 : "[nslbdp]GetAdjInfo dstLocalRankId[%u], phaseId[%u].", nslbAdjInfo.nsAdjInfo[i].dstLocalRankId,
92 : nslbAdjInfo.nsAdjInfo[i].phaseId);
93 : }
94 0 : return HCCL_SUCCESS;
95 0 : }
96 :
97 0 : HcclResult CollRunAlltoAllDirectFullmesh::MarkNeedAlltoallvCache()
98 : {
99 0 : needAlltoallvCache_ = true;
100 0 : HCCL_INFO(
101 : "[CollRunAlltoAllDirectFullmesh][MarkNeedAlltoallvCache] set needAlltoallvCache_[%u]"
102 : "for alltoallv aicpu cache",
103 : needAlltoallvCache_);
104 0 : return HCCL_SUCCESS;
105 : }
106 :
107 0 : HcclResult CollRunAlltoAllDirectFullmesh::GetHcclOffsetDstRanksMap(
108 : std::unordered_map<uint64_t, std::vector<uint32_t>>& hcclOffsetDstRanksMap) const
109 : {
110 0 : hcclOffsetDstRanksMap.clear();
111 0 : hcclOffsetDstRanksMap = hcclOffsetDstRanksMap_; // Deep copy
112 :
113 0 : return HCCL_SUCCESS;
114 : }
115 :
116 0 : HcclOpMetaInfo CollRunAlltoAllDirectFullmesh::GetOpMeta(HcclCMDType opType, const u64 size)
117 : {
118 : (void)opType;
119 0 : HcclOpMetaInfoDef opMeta = HcclOpMetaInfo::GetOneForAllToAllV(CopyPattern::ZCOPY, size, true);
120 0 : return opMeta;
121 : }
122 :
123 : HcclResult
124 0 : CollRunAlltoAllDirectFullmesh::GetLocalSDMAGroupInfo(const u32 userRank, u32& devNumInlocalPod, u32& rankIdxInPod)
125 : {
126 : (void)userRank;
127 0 : bool isA2MultiModule = topoAttr_.deviceType == DevType::DEV_TYPE_910B && !topoAttr_.isSingleMeshAggregation;
128 0 : if (static_cast<bool>(topoMatcher_->GetExternalInputInterHccsDisable()) || isA2MultiModule) {
129 0 : CHK_RET(topoMatcher_->GetLocalServerRankSize(topoAttr_.userRank, devNumInlocalPod, rankIdxInPod));
130 : } else {
131 0 : CHK_RET(topoMatcher_->GetLocalSuperPodRankSize(topoAttr_.userRank, devNumInlocalPod, rankIdxInPod));
132 : }
133 0 : CHK_PRT_RET(
134 : devNumInlocalPod == INVALID_VALUE_RANKSIZE,
135 : HCCL_ERROR("[CollRunAlltoAllDirectFullmesh][GetLocalSDMAGroupInfo]get local superPod total ranksize failed."),
136 : HCCL_E_PARA);
137 0 : return HCCL_SUCCESS;
138 : }
139 :
140 0 : HcclResult CollRunAlltoAllDirectFullmesh::CalcStreamNum(u32& streamNum)
141 : {
142 : // 每个超节点内的卡数
143 0 : u32 devNumInlocalPod = INVALID_VALUE_RANKSIZE;
144 0 : u32 rankIdxInPod = INVALID_VALUE_RANKID;
145 0 : CHK_RET(GetLocalSDMAGroupInfo(topoAttr_.userRank, devNumInlocalPod, rankIdxInPod));
146 :
147 : // 单超节点场景需要的从流数量
148 0 : streamNum = (devNumInlocalPod > ALLTOALLV_DIRECT_FULLMESH_SDMA_CONCURRENT_SIZE) ?
149 : (ALLTOALLV_DIRECT_FULLMESH_SDMA_CONCURRENT_SIZE * RANK_SET_COMPUTE_CONST) :
150 0 : (devNumInlocalPod * RANK_SET_COMPUTE_CONST);
151 :
152 : // 多超节点场景下,RDMA会设置独立的并发度
153 0 : if ((topoAttr_.userRankSize - devNumInlocalPod) > 0) {
154 0 : streamNum += 1; // 一条从流专门用来管理超节点间的RDMA通信
155 0 : u32 totalRdmaRankNum = topoAttr_.userRankSize - devNumInlocalPod;
156 0 : streamNum += (totalRdmaRankNum > ALLTOALLV_DIRECT_FULLMESH_RDMA_CONCURRENT_SIZE) ?
157 : (ALLTOALLV_DIRECT_FULLMESH_RDMA_CONCURRENT_SIZE) :
158 0 : (totalRdmaRankNum);
159 : }
160 :
161 0 : HCCL_INFO("[CollRunAlltoAllDirectFullmesh][CalcStreamNum] tag[%s] streamNum[%u]", tag_.c_str(), streamNum);
162 0 : return HCCL_SUCCESS;
163 : }
164 :
165 : // level0-level1 打平fullmesh
166 : // 超节点内建SDMA链路;超节点间建RDMA链路
167 0 : HcclResult CollRunAlltoAllDirectFullmesh::CalcLevel0CommInfo(
168 : TransportMemType inputType, TransportMemType outputType, std::vector<LevelNSubCommTransport>& opTransport)
169 : {
170 0 : CommParaInfo commCombinePara(COMM_COMBINE_ORDER, CommType::COMM_TAG_MESH);
171 0 : CHK_RET(CalcCommPlaneInfo(tag_, commCombinePara, opTransport[COMM_COMBINE_ORDER], inputType, outputType));
172 :
173 0 : LevelNSubCommTransport& commTransportLevel0 = opTransport[COMM_COMBINE_ORDER];
174 0 : for (u32 subCommIndex = 0; subCommIndex < commTransportLevel0.size(); subCommIndex++) {
175 0 : for (auto& transportRequest : commTransportLevel0[subCommIndex].transportRequests) {
176 0 : transportRequest.isUsedRdma = topoAttr_.isUsedRdmaMap.at(transportRequest.remoteUserRank);
177 : }
178 : }
179 0 : return HCCL_SUCCESS;
180 0 : }
181 :
182 : HcclResult
183 0 : CollRunAlltoAllDirectFullmesh::CalcTransportMemType(TransportMemType& inputType, TransportMemType& outputType)
184 : {
185 0 : inputType = TransportMemType::CCL_INPUT;
186 0 : outputType = TransportMemType::CCL_OUTPUT;
187 :
188 0 : HCCL_INFO(
189 : "[CollRunAlltoAllDirectFullmesh][CalcTransportMemType] tag[%s] inputType[%d], outputType[%d]", tag_.c_str(),
190 : inputType, outputType);
191 0 : return HCCL_SUCCESS;
192 : }
193 :
194 0 : HcclResult CollRunAlltoAllDirectFullmesh::CalcCommInfo(std::vector<LevelNSubCommTransport>& opTransport)
195 : {
196 0 : TransportMemType inputType = TransportMemType::RESERVED;
197 0 : TransportMemType outputType = TransportMemType::RESERVED;
198 :
199 0 : CHK_RET(CalcTransportMemType(inputType, outputType));
200 : // level0 - level1 全连接通信域
201 0 : CHK_RET(CalcLevel0CommInfo(inputType, outputType, opTransport));
202 0 : return HCCL_SUCCESS;
203 : }
204 :
205 0 : HcclResult CollRunAlltoAllDirectFullmesh::GetLocalSendRecvInfoforAlltoallV(const OpParam& param)
206 : {
207 : // 注意: 如果send/recv info的计算逻辑发生变化, 需要同步修改framework下的IsSmallDataAlltoallv()函数
208 0 : for (u32 j = 0; j < topoAttr_.userRankSize; j++) {
209 0 : u64 curSendCounts = *(static_cast<const u64*>(param.All2AllDataDes.sendCounts) + j);
210 0 : u64 curSendDispls = *(static_cast<const u64*>(param.All2AllDataDes.sdispls) + j);
211 0 : localSendRecvInfo_.sendCounts[j] = curSendCounts;
212 0 : localSendRecvInfo_.sendDispls[j] = curSendDispls;
213 0 : localSendRecvInfo_.sendLength[j] = curSendCounts * SIZE_TABLE[param.All2AllDataDes.sendType];
214 0 : localSendRecvInfo_.sendOffset[j] = curSendDispls * SIZE_TABLE[param.All2AllDataDes.sendType];
215 :
216 0 : u64 curRecvCounts = *(static_cast<const u64*>(param.All2AllDataDes.recvCounts) + j);
217 0 : u64 curRecvDispls = *(static_cast<const u64*>(param.All2AllDataDes.rdispls) + j);
218 0 : localSendRecvInfo_.recvCounts[j] = curRecvCounts;
219 0 : localSendRecvInfo_.recvDispls[j] = curRecvDispls;
220 0 : localSendRecvInfo_.recvLength[j] = curRecvCounts * SIZE_TABLE[param.All2AllDataDes.recvType];
221 0 : localSendRecvInfo_.recvOffset[j] = curRecvDispls * SIZE_TABLE[param.All2AllDataDes.recvType];
222 :
223 0 : HCCL_DEBUG(
224 : "GetLocalSendRecvInfoforAlltoallV rank[%u], sendCounts[%llu], sendDispls[%llu] "
225 : "recvCounts[%llu], recvDispls[%llu]",
226 : topoAttr_.userRank, localSendRecvInfo_.sendCounts[j], localSendRecvInfo_.sendDispls[j],
227 : localSendRecvInfo_.recvCounts[j], localSendRecvInfo_.recvDispls[j]);
228 : }
229 0 : return HCCL_SUCCESS;
230 : }
231 :
232 0 : HcclResult CollRunAlltoAllDirectFullmesh::GetLocalSendRecvInfoforAlltoall(const OpParam& param)
233 : {
234 0 : u64 curSendDispls = 0;
235 0 : u64 curSendOffset = 0;
236 0 : u64 curRecvDispls = 0;
237 0 : u64 curRecvOffset = 0;
238 0 : for (u32 j = 0; j < topoAttr_.userRankSize; j++) {
239 0 : u64 curSendCounts = param.All2AllDataDes.sendCount;
240 0 : u64 curSendLength = curSendCounts * SIZE_TABLE[param.All2AllDataDes.sendType];
241 0 : localSendRecvInfo_.sendCounts[j] = curSendCounts;
242 0 : localSendRecvInfo_.sendDispls[j] = curSendDispls;
243 0 : localSendRecvInfo_.sendLength[j] = curSendLength;
244 0 : localSendRecvInfo_.sendOffset[j] = curSendOffset;
245 0 : curSendDispls += curSendCounts;
246 0 : curSendOffset += curSendLength;
247 :
248 0 : u64 curRecvCounts = param.All2AllDataDes.sendCount;
249 0 : u64 curRecvLength = curRecvCounts * SIZE_TABLE[param.All2AllDataDes.recvType];
250 0 : localSendRecvInfo_.recvCounts[j] = curRecvCounts;
251 0 : localSendRecvInfo_.recvDispls[j] = curRecvDispls;
252 0 : localSendRecvInfo_.recvLength[j] = curRecvLength;
253 0 : localSendRecvInfo_.recvOffset[j] = curRecvOffset;
254 0 : curRecvDispls += curRecvCounts;
255 0 : curRecvOffset += curRecvLength;
256 0 : HCCL_DEBUG(
257 : "GetLocalSendRecvInfoforAlltoAll rank[%u], sendCounts[%llu], sendDispls[%llu] "
258 : "recvCounts[%llu], recvDispls[%llu]",
259 : topoAttr_.userRank, localSendRecvInfo_.sendCounts[j], localSendRecvInfo_.sendDispls[j],
260 : localSendRecvInfo_.recvCounts[j], localSendRecvInfo_.recvDispls[j]);
261 : }
262 0 : return HCCL_SUCCESS;
263 : }
264 :
265 0 : HcclResult CollRunAlltoAllDirectFullmesh::GetLocalSendRecvInfoforAlltoallVC(const OpParam& param)
266 : {
267 0 : u64 curSendDispls = 0;
268 0 : u64 curSendOffset = 0;
269 0 : u64 curRecvDispls = 0;
270 0 : u64 curRecvOffset = 0;
271 0 : u64 rankSize = topoAttr_.userRankSize;
272 0 : u64 usrRank = topoAttr_.userRank;
273 0 : for (u32 j = 0; j < topoAttr_.userRankSize; j++) {
274 0 : u64 curSendCounts = *(static_cast<const u64*>(param.All2AllDataDes.sendCountMatrix) + usrRank * rankSize + j);
275 0 : u64 curSendLength = curSendCounts * SIZE_TABLE[param.All2AllDataDes.sendType];
276 0 : localSendRecvInfo_.sendCounts[j] = curSendCounts;
277 0 : localSendRecvInfo_.sendDispls[j] = curSendDispls;
278 0 : localSendRecvInfo_.sendLength[j] = curSendLength;
279 0 : localSendRecvInfo_.sendOffset[j] = curSendOffset;
280 0 : curSendDispls += curSendCounts;
281 0 : curSendOffset += curSendLength;
282 :
283 0 : u64 curRecvCounts = *(static_cast<const u64*>(param.All2AllDataDes.sendCountMatrix) + usrRank + rankSize * j);
284 0 : u64 curRecvLength = curRecvCounts * SIZE_TABLE[param.All2AllDataDes.recvType];
285 0 : localSendRecvInfo_.recvCounts[j] = curRecvCounts;
286 0 : localSendRecvInfo_.recvDispls[j] = curRecvDispls;
287 0 : localSendRecvInfo_.recvLength[j] = curRecvLength;
288 0 : localSendRecvInfo_.recvOffset[j] = curRecvOffset;
289 0 : curRecvDispls += curRecvCounts;
290 0 : curRecvOffset += curRecvLength;
291 0 : HCCL_DEBUG(
292 : "GetLocalSendRecvInfoforAlltoallVC rank[%u], sendCounts[%llu], sendDispls[%llu] "
293 : "recvCounts[%llu], recvDispls[%llu]",
294 : topoAttr_.userRank, localSendRecvInfo_.sendCounts[j], localSendRecvInfo_.sendDispls[j],
295 : localSendRecvInfo_.recvCounts[j], localSendRecvInfo_.recvDispls[j]);
296 : }
297 0 : return HCCL_SUCCESS;
298 : }
299 :
300 0 : HcclResult CollRunAlltoAllDirectFullmesh::GetAlltoAllvTmpRankSendRecvInfo(const OpParam& param)
301 : {
302 0 : localSendRecvInfo_.sendCounts.resize(topoAttr_.userRankSize, 0);
303 0 : localSendRecvInfo_.sendDispls.resize(topoAttr_.userRankSize, 0);
304 0 : localSendRecvInfo_.sendLength.resize(topoAttr_.userRankSize, 0);
305 0 : localSendRecvInfo_.sendOffset.resize(topoAttr_.userRankSize, 0);
306 :
307 0 : localSendRecvInfo_.recvCounts.resize(topoAttr_.userRankSize, 0);
308 0 : localSendRecvInfo_.recvDispls.resize(topoAttr_.userRankSize, 0);
309 0 : localSendRecvInfo_.recvLength.resize(topoAttr_.userRankSize, 0);
310 0 : localSendRecvInfo_.recvOffset.resize(topoAttr_.userRankSize, 0);
311 0 : if (param.opType == HcclCMDType::HCCL_CMD_ALLTOALLV) {
312 0 : CHK_RET(GetLocalSendRecvInfoforAlltoallV(param));
313 0 : } else if (param.opType == HcclCMDType::HCCL_CMD_ALLTOALL) {
314 0 : CHK_RET(GetLocalSendRecvInfoforAlltoall(param));
315 0 : } else if (param.opType == HcclCMDType::HCCL_CMD_ALLTOALLVC) {
316 0 : CHK_RET(GetLocalSendRecvInfoforAlltoallVC(param));
317 : } else {
318 0 : HCCL_ERROR("Only support optype AllToAll , AllToAllV and AllToAllVC !");
319 : }
320 0 : return HCCL_SUCCESS;
321 : }
322 :
323 0 : HcclResult CollRunAlltoAllDirectFullmesh::KernelRun(const OpParam& param, ExecMem& execMem)
324 : {
325 0 : HCCL_CONFIG_INFO(HCCL_ALG, "[%s] AllToAll fullmesh start.", __func__);
326 :
327 : // 准备数据
328 0 : CHK_RET(ActiveSlaveStreams(param.stream));
329 0 : CHK_RET(GetAlltoAllvTmpRankSendRecvInfo(param));
330 :
331 : // 获取当前超节点内总卡数
332 0 : u32 devNumInlocalPod = INVALID_VALUE_RANKSIZE;
333 0 : u32 rankIdxInPod = INVALID_VALUE_RANKID;
334 0 : CHK_RET(GetLocalSDMAGroupInfo(topoAttr_.userRank, devNumInlocalPod, rankIdxInPod));
335 :
336 : // 获取通信域
337 0 : CHK_RET(CheckCommSize(COMM_COMBINE_ORDER, COMM_INDEX_0 + 1));
338 0 : SubCommInfo level0CommInfo = GetSubCommInfo(COMM_COMBINE_ORDER, COMM_INDEX_0);
339 0 : bool isA2MultiModule = topoAttr_.deviceType == DevType::DEV_TYPE_910B && !topoAttr_.isSingleMeshAggregation;
340 : // isSuPodAsym 表示A2A3卡数不一致场景或者A3多超节点server数不同场景
341 0 : bool isSuPodAsym = false;
342 0 : if (topoAttr_.superPodNum > 1) {
343 : isSuPodAsym
344 0 : = (static_cast<bool>(topoAttr_.multiModuleDiffDeviceNumMode)
345 0 : || static_cast<bool>(topoAttr_.multiSuperPodDiffServerNumMode));
346 : } else {
347 0 : isSuPodAsym = (static_cast<bool>(topoMatcher_->GetExternalInputInterHccsDisable()) || isA2MultiModule)
348 0 : && static_cast<bool>(topoAttr_.multiModuleDiffDeviceNumMode);
349 : }
350 :
351 : // 执行
352 : // 注意: 如果使用了非AlltoAllVDirectFullMesh的算法模板, 需要同步修改framework中的NeedOpUnfoldCache()函数
353 0 : std::unique_ptr<AlgTemplateBase> tempAlg = AlgTemplateRegistry::Instance().GetAlgTemplate(
354 0 : TemplateType::TEMPLATE_ALL_2_ALL_V_DIRECT_FULL_MESH, dispatcher_);
355 0 : HCCL_CONFIG_INFO(HCCL_ALG, "[%s] Run TEMPLATE_ALL_2_ALL_V_DIRECT_FULL_MESH in COMM_COMBINE_ORDER", __func__);
356 0 : CHK_SMART_PTR_NULL(tempAlg);
357 :
358 0 : PrepareData prepareData;
359 0 : prepareData.stream = param.stream;
360 0 : prepareData.userRank = topoAttr_.userRank;
361 0 : prepareData.userRankSize = topoAttr_.userRankSize;
362 0 : prepareData.linksPtr = &level0CommInfo.links;
363 0 : prepareData.localSendRecvInfoPtr = &localSendRecvInfo_;
364 0 : prepareData.devNumInlocalPod = devNumInlocalPod;
365 0 : prepareData.rankIdxInPod = rankIdxInPod;
366 :
367 0 : prepareData.inputMem = algResResp_->paramInputMem;
368 0 : prepareData.outputMem = algResResp_->paramOutputMem;
369 0 : prepareData.cclInMem = execMem.inputMem;
370 0 : prepareData.cclOutMem = execMem.outputMem;
371 0 : prepareData.workMode = workflowMode_;
372 0 : prepareData.subStreamsPtr = &algResResp_->slaveStreams;
373 0 : prepareData.signalPtr = &algResResp_->notifiesMain;
374 0 : prepareData.signalAuxPtr = &algResResp_->notifiesAux;
375 0 : prepareData.isSuPodAsym = isSuPodAsym;
376 0 : prepareData.opType = param.opType;
377 0 : prepareData.algOpContext = algOpContext_;
378 :
379 : // 如果使能alltoallv aicpu cache
380 0 : if (needAlltoallvCache_) {
381 : // 注意: 一定是alltoallv类算子才有可能设置needAlltoallvCache_, 让alltoallv temp alg感知cache并保存算法中间结果
382 0 : CHK_PRT_RET(
383 : !(param.opType == HcclCMDType::HCCL_CMD_ALLTOALLV || param.opType == HcclCMDType::HCCL_CMD_ALLTOALLVC),
384 : HCCL_ERROR(
385 : "[CollRunAlltoAllDirectFullmesh][KernelRun] needAlltoallvCache_[%u] opType[%u]", needAlltoallvCache_,
386 : param.opType),
387 : HCCL_E_INTERNAL);
388 :
389 : // 使能alltoallv temp alg感知alltoallv aicpu cache
390 0 : prepareData.needAlltoallvCache = true;
391 : } else {
392 0 : prepareData.needAlltoallvCache = false;
393 : }
394 :
395 0 : CHK_RET(tempAlg->Prepare(prepareData));
396 :
397 0 : CHK_RET(tempAlg->RunAsync());
398 :
399 0 : if (needAlltoallvCache_) {
400 : // 在tempAlg被销毁前保存hcclOffset-dstRank之间的mapping信息
401 : // 注意: CollRunAlltoAllDirectFullmesh executor使用的一定是AlltoAllVDirectFullMesh template
402 0 : hcclOffsetDstRanksMap_.clear();
403 0 : HCCL_INFO(
404 : "[CollRunAlltoAllDirectFullmesh][KernelRun] get hcclOffset-dstRanks mapping for AlltoAllVDirectFullMesh");
405 0 : CHK_RET(tempAlg->GetHcclOffsetDstRanksMap(hcclOffsetDstRanksMap_));
406 : }
407 :
408 0 : HCCL_INFO("[CollRunAlltoAllDirectFullmesh] executor run success.");
409 0 : if (algOpContext_.opRetryHandler.isPostSync == true) {
410 0 : OpParam postSyncParam = param;
411 0 : if ((*prepareData.subStreamsPtr).size() == 0) {
412 0 : CHK_RET(PostSyncWithoutSubstream(postSyncParam, execMem));
413 : } else {
414 0 : PrepareData postSyncPrepareData = prepareData;
415 0 : CHK_RET(PostSyncWithSubstream(postSyncParam, execMem, postSyncPrepareData));
416 0 : }
417 0 : }
418 0 : return HCCL_SUCCESS;
419 0 : }
420 0 : HcclResult CollRunAlltoAllDirectFullmesh::Getlevel1CommRank(SubCommInfo& level1CommInfo)
421 : {
422 0 : HCCL_INFO(
423 : "[GetAdjInfo-nslbdp] Getlevel1CommRank userRank[%u]--userRankSize[%u].", topoAttr_.userRank,
424 : topoAttr_.userRankSize);
425 0 : level1CommInfo.localRank = topoAttr_.userRank;
426 0 : level1CommInfo.localRankSize = topoAttr_.userRankSize;
427 0 : return HCCL_SUCCESS;
428 : }
429 :
430 : HcclResult
431 0 : CollRunAlltoAllDirectFullmesh::SelectTempAlg(std::unique_ptr<AlgTemplateBase>& level1TempAlg, u32 level1RankSize)
432 : {
433 : (void)level1RankSize;
434 0 : HCCL_INFO("[GetAdjInfo-nslbdp] SelectTempAlg.");
435 0 : level1TempAlg = AlgTemplateRegistry::Instance().GetAlgTemplate(
436 0 : TemplateType::TEMPLATE_ALL_2_ALL_V_DIRECT_FULL_MESH, dispatcher_);
437 0 : CHK_SMART_PTR_NULL(level1TempAlg);
438 :
439 0 : return HCCL_SUCCESS;
440 : }
441 :
442 0 : HcclResult CollRunAlltoAllDirectFullmesh::GetDevNumInlocalPod(u32& devNumInlocalPod)
443 : {
444 0 : HCCL_INFO("[GetAdjInfo-nslbdp] GetDevNumInlocalPod.");
445 : // 获取当前超节点内总卡数
446 0 : u32 rankIdxInPod = INVALID_VALUE_RANKID;
447 0 : CHK_RET(GetLocalSDMAGroupInfo(topoAttr_.userRank, devNumInlocalPod, rankIdxInPod));
448 :
449 0 : return HCCL_SUCCESS;
450 : }
451 : REGISTER_EXEC("RunAlltoAllDirectFullmesh", AlltoAllVDirectFullMesh, CollRunAlltoAllDirectFullmesh);
452 : } // namespace hccl
|