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/hccl_res.h"
12 : #include "log.h"
13 : #include "hccl_comm_pub.h"
14 : #include "independent_op.h"
15 : #include <string>
16 : #include "param_check_pub.h"
17 : #include "hccl_comm.h"
18 : #include "hccl_inner.h"
19 : #include "rank_graph.h"
20 : #include "rank_graph_v2.h"
21 : #include "op_base_v2.h"
22 : #include "hccl_independent_common.h"
23 :
24 : using namespace hccl;
25 :
26 : #ifndef CCL_KERNEL_AICPU
27 0 : HcclResult HcclGetRankGraph(HcclComm comm, GraphType type, void **graph, uint32_t *len)
28 : {
29 0 : CHK_PTR_NULL(comm);
30 0 : CHK_PTR_NULL(graph);
31 0 : CHK_PTR_NULL(len);
32 0 : hccl::hcclComm *hcclComm = static_cast<hccl::hcclComm *>(comm);
33 0 : HcclResult ret = HCCL_SUCCESS;
34 0 : if (hcclComm->IsCommunicatorV2()) {
35 0 : CollComm* collComm = hcclComm->GetCollComm();
36 0 : CHK_PTR_NULL(collComm);
37 0 : RankGraph* rankGraph = collComm->GetRankGraph();
38 0 : CHK_PTR_NULL(rankGraph);
39 0 : ret = rankGraph->GetRankGraphInfo(type, graph, len);
40 : }
41 : else {
42 0 : ret = hcclComm->GetRankGraph(type, graph, len);
43 : }
44 0 : if (ret != HCCL_SUCCESS) {
45 0 : HCCL_ERROR("[%s] Failed to HcclGetRankGraph ret[%d]", __func__, ret);
46 0 : return ret;
47 : }
48 0 : HCCL_RUN_INFO("[%s] success, group[%s], len[%u]", __func__, hcclComm->GetIdentifier().c_str(), *len);
49 0 : return HCCL_SUCCESS;
50 : }
51 :
52 19 : static inline HcclResult GetRankGraphFromComm(HcclComm comm, RankGraph** rankGraph)
53 : {
54 19 : CHK_PTR_NULL(comm);
55 19 : CHK_PTR_NULL(rankGraph);
56 19 : hccl::hcclComm* hcclComm = static_cast<hccl::hcclComm*>(comm);
57 19 : CollComm* collComm = hcclComm->GetCollComm();
58 19 : CHK_PTR_NULL(collComm);
59 19 : *rankGraph = collComm->GetRankGraph();
60 19 : CHK_PTR_NULL(*rankGraph);
61 19 : return HCCL_SUCCESS;
62 : }
63 :
64 4 : HcclResult HcclRankGraphGetLinks(HcclComm comm, uint32_t netLayer, uint32_t srcRank, uint32_t dstRank,
65 : CommLink **links, uint32_t *linkNum)
66 : {
67 4 : CHK_PTR_NULL(comm);
68 3 : CHK_PTR_NULL(links);
69 2 : CHK_PTR_NULL(linkNum);
70 2 : HcclResult ret = HCCL_SUCCESS;
71 4 : HCCLV2_FUNC_RUN(
72 : [&]() -> HcclResult {
73 : if (srcRank == dstRank) {
74 : HCCL_ERROR("[%s] srcRank[%u] and dstRank[%u] is same", __func__, srcRank, dstRank);
75 : return HCCL_E_PARA;
76 : }
77 : RankGraph* rankGraph = nullptr;
78 : CHK_RET(GetRankGraphFromComm(comm, &rankGraph));
79 : CHK_RET(rankGraph->GetLinks(netLayer, srcRank, dstRank, links, linkNum));
80 : HCCL_INFO("HcclRankGraphGetLinks success with netLayer[%u], srcRank[%u], dstRank[%u], output linkNum[%u]",
81 : netLayer, srcRank, dstRank, *linkNum);
82 : return HCCL_SUCCESS;
83 : }());
84 0 : hccl::hcclComm *hcclComm = static_cast<hccl::hcclComm *>(comm);
85 0 : HCCL_RUN_INFO("Entry-%s: comm[%s], netLayer[%u], srcRank[%u], dstRank[%u]", __func__,
86 : hcclComm->GetIdentifier().c_str(), netLayer, srcRank, dstRank);
87 0 : ret = hcclComm->GetLinks(netLayer, srcRank, dstRank, links, linkNum);
88 0 : if (ret != HCCL_SUCCESS) {
89 0 : HCCL_ERROR("[%s] Failed to get links for netLayer[%d], srcRank[%u], dstRank[%u] ret[%d]",
90 : __func__, netLayer, srcRank, dstRank, ret);
91 0 : return ret;
92 : }
93 0 : HCCL_RUN_INFO("[%s] success: comm[%s] linkNum[%u]", __func__, hcclComm->GetIdentifier().c_str(), *linkNum);
94 0 : return HCCL_SUCCESS;
95 : }
96 :
97 3 : HcclResult HcclRankGraphGetLayers(HcclComm comm, uint32_t** netLayers, uint32_t* netLayerNum)
98 : {
99 3 : CHK_PTR_NULL(comm);
100 2 : CHK_PTR_NULL(netLayers);
101 1 : CHK_PTR_NULL(netLayerNum);
102 1 : HcclResult ret = HCCL_SUCCESS;
103 2 : HCCLV2_FUNC_RUN([&]() -> HcclResult {
104 : RankGraph* rankGraph = nullptr;
105 : CHK_RET(GetRankGraphFromComm(comm, &rankGraph));
106 : CHK_RET(rankGraph->GetNetLayers(netLayers, netLayerNum));
107 : HCCL_INFO("HcclRankGraphGetLayers success, netLayerNum [%u]", *netLayerNum);
108 : return HCCL_SUCCESS;
109 : }());
110 0 : hccl::hcclComm* hcclComm = static_cast<hccl::hcclComm*>(comm);
111 0 : ret = hcclComm->GetNetLayers(netLayers, netLayerNum);
112 0 : if (ret != HCCL_SUCCESS) {
113 0 : HCCL_ERROR("[%s] Failed to GetCommNetLayers ret[%d]", __func__, ret);
114 0 : return ret;
115 : }
116 0 : HCCL_RUN_INFO("[%s] success, group[%s], netLayerNum size[%u]", __func__, hcclComm->GetIdentifier().c_str(), *netLayerNum);
117 0 : return HCCL_SUCCESS;
118 : }
119 :
120 3 : HcclResult HcclRankGraphGetTopoTypeByLayer(HcclComm comm, uint32_t netLayer, CommTopo *topoType)
121 : {
122 3 : CHK_PTR_NULL(comm);
123 2 : CHK_PTR_NULL(topoType);
124 2 : HcclResult ret = HCCL_SUCCESS;
125 4 : HCCLV2_FUNC_RUN(
126 : [&]() -> HcclResult {
127 : RankGraph* rankGraph = nullptr;
128 : CHK_RET(GetRankGraphFromComm(comm, &rankGraph));
129 : CHK_RET(rankGraph->GetInstTopoTypeByNetLayer(netLayer, topoType));
130 : HCCL_INFO("HcclRankGraphGetTopoTypeByLayer success, topoType [%d]", *topoType);
131 : return HCCL_SUCCESS;
132 : }());
133 0 : hccl::hcclComm *hcclComm = static_cast<hccl::hcclComm *>(comm);
134 0 : ret = hcclComm->GetInstTopoTypeByNetLayer(netLayer, topoType);
135 0 : if (ret != HCCL_SUCCESS) {
136 0 : HCCL_ERROR("[%s] Failed, ret[%d]", __func__, ret);
137 0 : return ret;
138 : }
139 0 : HCCL_RUN_INFO("[%s] success, group[%s], [%d]", __func__, hcclComm->GetIdentifier().c_str(), *topoType);
140 0 : return HCCL_SUCCESS;
141 : }
142 :
143 3 : HcclResult HcclRankGraphGetRankSizeByLayer(HcclComm comm, uint32_t netLayer, uint32_t *rankNum)
144 : {
145 3 : CHK_PTR_NULL(comm);
146 2 : CHK_PTR_NULL(rankNum);
147 :
148 2 : HcclResult ret = HCCL_SUCCESS;
149 4 : HCCLV2_FUNC_RUN(
150 : [&]() -> HcclResult {
151 : RankGraph* rankGraph = nullptr;
152 : CHK_RET(GetRankGraphFromComm(comm, &rankGraph));
153 : CHK_RET(rankGraph->GetInstSizeByNetLayer(netLayer, rankNum));
154 : HCCL_INFO("HcclRankGraphGetRankSizeByLayer success, rankNum [%u]", *rankNum);
155 : return HCCL_SUCCESS;
156 : }());
157 0 : hccl::hcclComm *hcclComm = static_cast<hccl::hcclComm *>(comm);
158 0 : ret = hcclComm->GetInstSizeByNetLayer(netLayer, rankNum);
159 0 : if (ret != HCCL_SUCCESS) {
160 0 : HCCL_ERROR("[%s] Failed, ret[%d]", __func__, ret);
161 0 : return ret;
162 : }
163 0 : HCCL_RUN_INFO("[%s] success, group[%s], rankNum[%u]", __func__, hcclComm->GetIdentifier().c_str(), *rankNum);
164 0 : return HCCL_SUCCESS;
165 : }
166 :
167 4 : HcclResult HcclRankGraphGetRanksByLayer(HcclComm comm, uint32_t netLayer, uint32_t **ranks, uint32_t *rankNum)
168 : {
169 4 : CHK_PTR_NULL(comm);
170 3 : CHK_PTR_NULL(rankNum);
171 3 : CHK_PTR_NULL(ranks);
172 2 : HcclResult ret = HCCL_SUCCESS;
173 4 : HCCLV2_FUNC_RUN(
174 : [&]() -> HcclResult {
175 : RankGraph* rankGraph = nullptr;
176 : CHK_RET(GetRankGraphFromComm(comm, &rankGraph));
177 : CHK_RET(rankGraph->GetInstRanksByNetLayer(netLayer, ranks, rankNum));
178 : HCCL_INFO("HcclRankGraphGetRanksByLayer success, rankNum [%u]", *rankNum);
179 : return HCCL_SUCCESS;
180 : }());
181 0 : hccl::hcclComm *hcclComm = static_cast<hccl::hcclComm *>(comm);
182 0 : ret = hcclComm->GetInstRanksByNetLayer(netLayer, ranks, rankNum);
183 0 : if (ret != HCCL_SUCCESS) {
184 0 : HCCL_ERROR("[%s] Failed, ret[%d]", __func__, ret);
185 0 : return ret;
186 : }
187 0 : HCCL_RUN_INFO("[%s] success, group[%s], rankNum[%u]", __func__, hcclComm->GetIdentifier().c_str(), *rankNum);
188 0 : return HCCL_SUCCESS;
189 : }
190 :
191 4 : HcclResult HcclRankGraphGetInstSizeListByLayer(HcclComm comm, uint32_t netLayer, uint32_t **instSizeList, uint32_t *listSize)
192 : {
193 4 : CHK_PTR_NULL(comm);
194 3 : CHK_PTR_NULL(instSizeList);
195 2 : CHK_PTR_NULL(listSize);
196 2 : HcclResult ret = HCCL_SUCCESS;
197 4 : HCCLV2_FUNC_RUN(
198 : [&]() -> HcclResult {
199 : RankGraph* rankGraph = nullptr;
200 : CHK_RET(GetRankGraphFromComm(comm, &rankGraph));
201 : CHK_RET(rankGraph->GetInstSizeListByNetLayer(netLayer, instSizeList, listSize));
202 : HCCL_INFO("HcclRankGraphGetInstSizeListByLayer success, listSize [%u]", *listSize);
203 : return HCCL_SUCCESS;
204 : }());
205 0 : hccl::hcclComm *hcclComm = static_cast<hccl::hcclComm *>(comm);
206 0 : ret = hcclComm->GetInstSizeListByNetLayer(netLayer, instSizeList, listSize);
207 0 : if (ret != HCCL_SUCCESS) {
208 0 : HCCL_ERROR("[%s] Failed, ret[%d]", __func__, ret);
209 0 : return ret;
210 : }
211 0 : HCCL_RUN_INFO("[%s] success, group[%s], listSize[%u]", __func__, hcclComm->GetIdentifier().c_str(), *listSize);
212 0 : return HCCL_SUCCESS;
213 : }
214 :
215 1 : HcclResult HcclRankGraphGetTopoInstsByLayer(HcclComm comm, uint32_t netLayer, uint32_t **topoInsts, uint32_t *topoInstNum)
216 : {
217 1 : CHK_PTR_NULL(comm);
218 1 : CHK_PTR_NULL(topoInsts);
219 1 : CHK_PTR_NULL(topoInstNum);
220 2 : HCCLV2_FUNC_RUN(
221 : [&]() -> HcclResult {
222 : RankGraph* rankGraph = nullptr;
223 : CHK_RET(GetRankGraphFromComm(comm, &rankGraph));
224 : RankGraphV2* rankGraphV2 = static_cast<RankGraphV2*>(rankGraph);
225 : CHK_RET(rankGraphV2->GetTopoInstsByLayer(netLayer, topoInsts, topoInstNum));
226 : HCCL_INFO("HcclRankGraphGetTopoInstsByLayer success, topoInstNum [%u]", *topoInstNum);
227 : return HCCL_SUCCESS;
228 : }());
229 :
230 0 : hccl::hcclComm *hcclComm = static_cast<hccl::hcclComm *>(comm);
231 0 : HcclResult ret = hcclComm->GetTopoInstsByLayer(netLayer, topoInsts, topoInstNum);
232 :
233 0 : return ret;
234 : }
235 :
236 2 : HcclResult HcclRankGraphGetTopoType(HcclComm comm, uint32_t netLayer, uint32_t topoInstId, CommTopo *topoType)
237 : {
238 2 : CHK_PTR_NULL(comm);
239 2 : CHK_PTR_NULL(topoType);
240 4 : HCCLV2_FUNC_RUN(
241 : [&]() -> HcclResult {
242 : RankGraph* rankGraph = nullptr;
243 : CHK_RET(GetRankGraphFromComm(comm, &rankGraph));
244 : RankGraphV2* rankGraphV2 = static_cast<RankGraphV2*>(rankGraph);
245 : CHK_RET(rankGraphV2->GetTopoType(netLayer, topoInstId, topoType));
246 : HCCL_INFO("HcclRankGraphGetTopoType success, topoType [%d]", *topoType);
247 : return HCCL_SUCCESS;
248 : }());
249 0 : hccl::hcclComm *hcclComm = static_cast<hccl::hcclComm *>(comm);
250 0 : HcclResult ret = hcclComm->GetTopoType(netLayer, topoInstId, topoType);
251 0 : return ret;
252 : }
253 :
254 2 : HcclResult HcclRankGraphGetRanksByTopoInst(HcclComm comm, uint32_t netLayer, uint32_t topoInstId, uint32_t **ranks, uint32_t *rankNum)
255 : {
256 2 : CHK_PTR_NULL(comm);
257 2 : CHK_PTR_NULL(ranks);
258 2 : CHK_PTR_NULL(rankNum);
259 4 : HCCLV2_FUNC_RUN(
260 : [&]() -> HcclResult {
261 : RankGraph* rankGraph = nullptr;
262 : CHK_RET(GetRankGraphFromComm(comm, &rankGraph));
263 : RankGraphV2* rankGraphV2 = static_cast<RankGraphV2*>(rankGraph);
264 : CHK_RET(rankGraphV2->GetRanksByTopoInst(netLayer, topoInstId, ranks, rankNum));
265 : HCCL_INFO("HcclRankGraphGetRanksByTopoInst success, rankNum [%u]", *rankNum);
266 : return HCCL_SUCCESS;
267 : }());
268 0 : hccl::hcclComm *hcclComm = static_cast<hccl::hcclComm *>(comm);
269 0 : HcclResult ret = hcclComm->GetRanksByTopoInst(netLayer, topoInstId, ranks, rankNum);
270 0 : return ret;
271 : }
272 :
273 1 : HcclResult HcclRankGraphGetEndpointNum(HcclComm comm, uint32_t layer, uint32_t topoInstId, uint32_t *num)
274 : {
275 1 : CHK_PTR_NULL(comm);
276 1 : CHK_PTR_NULL(num);
277 2 : HCCLV2_FUNC_RUN(
278 : [&]() -> HcclResult {
279 : RankGraph* rankGraph = nullptr;
280 : CHK_RET(GetRankGraphFromComm(comm, &rankGraph));
281 : RankGraphV2* rankGraphV2 = static_cast<RankGraphV2*>(rankGraph);
282 : CHK_RET(rankGraphV2->GetEndpointNum(layer, topoInstId, num));
283 : HCCL_INFO("HcclRankGraphGetEndpointNum success, num [%u]", *num);
284 : return HCCL_SUCCESS;
285 : }());
286 0 : hccl::hcclComm *hcclComm = static_cast<hccl::hcclComm *>(comm);
287 0 : HcclResult ret = hcclComm->GetEndpointNum(layer, topoInstId, num);
288 0 : return ret;
289 : }
290 :
291 1 : HcclResult HcclRankGraphGetEndpointDesc(HcclComm comm, uint32_t layer, uint32_t topoInstId, uint32_t *descNum, EndpointDesc *endpointDesc)
292 : {
293 1 : CHK_PTR_NULL(comm);
294 1 : CHK_PTR_NULL(descNum);
295 1 : CHK_PTR_NULL(endpointDesc);
296 2 : HCCLV2_FUNC_RUN(
297 : [&]() -> HcclResult {
298 : RankGraph* rankGraph = nullptr;
299 : CHK_RET(GetRankGraphFromComm(comm, &rankGraph));
300 : RankGraphV2* rankGraphV2 = static_cast<RankGraphV2*>(rankGraph);
301 : CHK_RET(rankGraphV2->GetEndpointDesc(layer, topoInstId, descNum, endpointDesc));
302 : HCCL_INFO("HcclRankGraphGetEndpointDesc success");
303 : return HCCL_SUCCESS;
304 : }());
305 0 : hccl::hcclComm *hcclComm = static_cast<hccl::hcclComm *>(comm);
306 0 : HcclResult ret = hcclComm->GetEndpointDesc(layer, topoInstId, descNum, endpointDesc);
307 :
308 0 : return ret;
309 : }
310 :
311 0 : HcclResult HcclRankGraphGetEndpointInfo(HcclComm comm, uint32_t rankId, const EndpointDesc *endpointDesc, EndpointAttr endpointAttr, uint32_t infoLen, void *info)
312 : {
313 0 : CHK_PTR_NULL(comm);
314 0 : CHK_PTR_NULL(endpointDesc);
315 0 : CHK_PTR_NULL(info);
316 0 : HCCLV2_FUNC_RUN(
317 : [&]() -> HcclResult {
318 : RankGraph* rankGraph = nullptr;
319 : CHK_RET(GetRankGraphFromComm(comm, &rankGraph));
320 : RankGraphV2* rankGraphV2 = static_cast<RankGraphV2*>(rankGraph);
321 : CHK_RET(rankGraphV2->GetEndpointInfo(rankId, endpointDesc, endpointAttr, infoLen, info));
322 : HCCL_INFO("HcclRankGraphGetEndpointInfo success");
323 : return HCCL_SUCCESS;
324 : }());
325 0 : RankGraph* rankGraph = nullptr;
326 0 : CHK_RET(GetRankGraphFromComm(comm, &rankGraph));
327 0 : HcclResult ret = rankGraph->GetEndpointInfo(rankId, endpointDesc, endpointAttr, infoLen, info);
328 0 : if (ret != HCCL_SUCCESS) {
329 0 : HCCL_ERROR("[%s] Failed to get endpoint info, ret[%d]", __func__, ret);
330 0 : return ret;
331 : }
332 0 : HCCL_INFO("HcclRankGraphGetEndpointInfo success");
333 0 : return HCCL_SUCCESS;
334 : }
335 :
336 0 : HcclResult HcclGetHeterogMode(HcclComm comm, HcclHeterogMode *mode)
337 : {
338 0 : CHK_PTR_NULL(comm);
339 0 : CHK_PTR_NULL(mode);
340 0 : HCCLV2_FUNC_RUN(HcclGetHeterogModeV2(comm, mode));
341 0 : hccl::hcclComm *hcclComm = static_cast<hccl::hcclComm *>(comm);
342 0 : HcclResult ret = hcclComm->GetHeterogMode(mode);
343 0 : if (ret != HCCL_SUCCESS) {
344 0 : HCCL_ERROR("[%s] Failed, ret[%d]", __func__, ret);
345 0 : return ret;
346 : }
347 0 : HCCL_RUN_INFO("[%s] success, group[%s], mode[%u]", __func__, hcclComm->GetIdentifier().c_str(), *mode);
348 0 : return HCCL_SUCCESS;
349 : }
350 :
351 4 : HcclResult HcclGetRankSize(HcclComm comm, uint32_t *rankSize)
352 : {
353 : // 入参合法性校验
354 4 : CHK_PTR_NULL(comm);
355 2 : CHK_PTR_NULL(rankSize);
356 2 : HCCLV2_FUNC_RUN(
357 : [&]() -> HcclResult {
358 : RankGraph* rankGraph = nullptr;
359 : CHK_RET(GetRankGraphFromComm(comm, &rankGraph));
360 : CHK_RET(rankGraph->GetRankSize(rankSize));
361 : return HCCL_SUCCESS;
362 : }());
363 0 : hccl::hcclComm* hcclComm = static_cast<hccl::hcclComm *>(comm);
364 0 : u32 tmpRankSize = INVALID_VALUE_RANKSIZE;
365 0 : CHK_RET(hcclComm->GetRankSize(tmpRankSize));
366 0 : *rankSize = tmpRankSize;
367 : /* 关键状态记录 */
368 0 : HCCL_INFO("HcclGetRankSize success, rankSizePtr[%p], rankSize[%u]", rankSize, tmpRankSize);
369 0 : return HCCL_SUCCESS;
370 : }
371 :
372 2 : HcclResult HcclGetRankId(HcclComm comm, uint32_t *rank)
373 : {
374 : // 入参合法性校验
375 2 : CHK_PTR_NULL(comm);
376 0 : CHK_PTR_NULL(rank);
377 0 : HCCLV2_FUNC_RUN(
378 : [&]() -> HcclResult {
379 : RankGraph* rankGraph = nullptr;
380 : CHK_RET(GetRankGraphFromComm(comm, &rankGraph));
381 : CHK_RET(rankGraph->GetRankId(rank));
382 : return HCCL_SUCCESS;
383 : }());
384 0 : hccl::hcclComm *hcclComm = static_cast<hccl::hcclComm *>(comm);
385 0 : u32 tmpRankId = INVALID_VALUE_RANKID;
386 0 : CHK_RET(hcclComm->GetUserRank(tmpRankId));
387 0 : *rank = tmpRankId;
388 : /* 关键状态记录 */
389 0 : HCCL_INFO("HcclGetRankId success, rankIdPtr[%p], rankId[%u]", rank, tmpRankId);
390 0 : return HCCL_SUCCESS;
391 : }
392 : #endif
393 :
394 : #ifdef __cplusplus
395 : extern "C" {
396 : #endif // __cplusplus
397 0 : HcclResult CommGetNetLayers(HcclComm comm, uint32_t **netLayers, uint32_t *netLayerNum)
398 : {
399 0 : CHK_PTR_NULL(comm);
400 0 : CHK_PTR_NULL(netLayers);
401 0 : CHK_PTR_NULL(netLayerNum);
402 0 : HCCLV2_FUNC_RUN(HcclGetNetLayersV2(comm, netLayers, netLayerNum));
403 0 : hccl::hcclComm *hcclComm = static_cast<hccl::hcclComm *>(comm);
404 0 : HcclResult ret = hcclComm->CommGetNetLayers(netLayers, netLayerNum);
405 0 : if (ret != HCCL_SUCCESS) {
406 0 : HCCL_ERROR("[%s] Failed to GetCommNetLayers ret[%d]", __func__, ret);
407 0 : return ret;
408 : }
409 0 : HCCL_RUN_INFO("[%s] success, group[%s], netLayerNum size[%u]", __func__, hcclComm->GetIdentifier().c_str(), *netLayerNum);
410 0 : return HCCL_SUCCESS;
411 : }
412 :
413 0 : HcclResult CommGetInstTopoTypeByNetLayer(HcclComm comm, uint32_t netLayer, uint32_t *topoType)
414 : {
415 0 : CHK_PTR_NULL(comm);
416 0 : CHK_PTR_NULL(topoType);
417 0 : HCCLV2_FUNC_RUN(HcclGetInstTopoTypeByNetLayerV2(comm, netLayer, topoType));
418 :
419 0 : hccl::hcclComm *hcclComm = static_cast<hccl::hcclComm *>(comm);
420 0 : HcclResult ret = hcclComm->CommGetInstTopoTypeByNetLayer(netLayer, topoType);
421 0 : if (ret != HCCL_SUCCESS) {
422 0 : HCCL_ERROR("[%s] Failed, ret[%d]", __func__, ret);
423 0 : return ret;
424 : }
425 0 : HCCL_RUN_INFO("[%s] success, group[%s], [%d]", __func__, hcclComm->GetIdentifier().c_str(), *topoType);
426 0 : return HCCL_SUCCESS;
427 : }
428 :
429 0 : HcclResult CommGetInstSizeByNetLayer(HcclComm comm, uint32_t netLayer, uint32_t *rankNum)
430 : {
431 0 : CHK_PTR_NULL(comm);
432 0 : CHK_PTR_NULL(rankNum);
433 0 : HCCLV2_FUNC_RUN(HcclGetInstSizeByNetLayerV2(comm, netLayer, rankNum));
434 :
435 0 : hccl::hcclComm *hcclComm = static_cast<hccl::hcclComm *>(comm);
436 0 : HcclResult ret = hcclComm->CommGetInstSizeByNetLayer(netLayer, rankNum);
437 0 : if (ret != HCCL_SUCCESS) {
438 0 : HCCL_ERROR("[%s] Failed, ret[%d]", __func__, ret);
439 0 : return ret;
440 : }
441 0 : HCCL_RUN_INFO("[%s] success, group[%s], rankNum[%u]", __func__, hcclComm->GetIdentifier().c_str(), *rankNum);
442 0 : return HCCL_SUCCESS;
443 : }
444 : #ifdef __cplusplus
445 : }
446 : #endif // __cplusplus
|