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