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 "rank_graph_v2.h"
12 :
13 : namespace hccl {
14 :
15 0 : RankGraphV2::RankGraphV2() {}
16 :
17 225 : RankGraphV2::~RankGraphV2() {}
18 :
19 130 : RankGraphV2::RankGraphV2(void *rankGraphPtr)
20 : {
21 130 : pImpl = std::make_unique<Hccl::IRankGraph>(rankGraphPtr);
22 130 : }
23 :
24 301 : HcclResult RankGraphV2::GetRankSize(uint32_t *rankSize)
25 : {
26 301 : return pImpl->GetRankSize(rankSize);
27 : }
28 :
29 2 : HcclResult RankGraphV2::GetDevicePort(const uint32_t rank, uint32_t *devPort)
30 : {
31 2 : CHK_RET(pImpl->GetDevicePort(rank, devPort));
32 2 : return HCCL_SUCCESS;
33 : }
34 :
35 33 : HcclResult RankGraphV2::GetListenPort(const uint32_t rank, uint32_t *listenPort, EndpointLocType locType)
36 : {
37 33 : if (locType == EndpointLocType::ENDPOINT_LOC_TYPE_DEVICE) {
38 33 : CHK_RET(pImpl->GetDevicePort(rank, listenPort));
39 0 : } else if (locType == EndpointLocType::ENDPOINT_LOC_TYPE_HOST) {
40 0 : CHK_RET(pImpl->GetHostPort(rank, listenPort));
41 : } else {
42 0 : HCCL_ERROR("[%s] Invalid locType[%d] for rank[%u]", __func__, locType, rank);
43 0 : return HcclResult::HCCL_E_PARA;
44 : }
45 33 : return HCCL_SUCCESS;
46 : }
47 :
48 0 : HcclResult RankGraphV2::GetRankId(uint32_t *rank)
49 : {
50 0 : return pImpl->GetRankId(rank);
51 : }
52 :
53 2 : HcclResult RankGraphV2::GetLinks(uint32_t netLayer, uint32_t srcRank, uint32_t dstRank, CommLink **linkList,
54 : uint32_t *listSize)
55 : {
56 2 : return pImpl->GetLinks(netLayer, srcRank, dstRank, linkList, listSize);
57 : }
58 :
59 0 : HcclResult RankGraphV2::GetRankGraphInfo(GraphType type, void **graph, uint32_t *len)
60 : {
61 0 : return pImpl->GetRankGraphInfo(graph, len);
62 : }
63 :
64 24 : HcclResult RankGraphV2::GetDeviceId(uint32_t rankId, uint32_t *deviceId)
65 : {
66 24 : return pImpl->GetDeviceId(rankId, deviceId);
67 : }
68 :
69 1 : HcclResult RankGraphV2::GetNetLayers(uint32_t **netLayers, uint32_t *netLayerNum)
70 : {
71 1 : return pImpl->GetNetLayers(netLayers, netLayerNum);
72 : }
73 :
74 2 : HcclResult RankGraphV2::GetInstTopoTypeByNetLayer(uint32_t netLayer, CommTopo *topoType)
75 : {
76 2 : return pImpl->GetInstTopoTypeByNetLayer(netLayer, topoType);
77 : }
78 :
79 2 : HcclResult RankGraphV2::GetInstSizeByNetLayer(uint32_t netLayer, uint32_t *rankNum)
80 : {
81 2 : return pImpl->GetInstSizeByNetLayer(netLayer, rankNum);
82 : }
83 :
84 2 : HcclResult RankGraphV2::GetInstRanksByNetLayer(uint32_t netLayer, uint32_t **rankList, uint32_t *rankNum)
85 : {
86 2 : return pImpl->GetInstRanksByNetLayer(netLayer, rankList, rankNum);
87 : }
88 :
89 2 : HcclResult RankGraphV2::GetInstSizeListByNetLayer(uint32_t netLayer, uint32_t **instSizeList, uint32_t *listSize)
90 : {
91 2 : return pImpl->GetInstSizeListByNetLayer(netLayer, instSizeList, listSize);
92 : }
93 :
94 1 : HcclResult RankGraphV2::GetTopoInstsByLayer(uint32_t netLayer, uint32_t** topoInsts, uint32_t* topoInstNum)
95 : {
96 1 : return pImpl->GetTopoInstsByLayer(netLayer, topoInsts, topoInstNum);
97 : }
98 :
99 2 : HcclResult RankGraphV2::GetTopoType(const uint32_t netLayer, const uint32_t topoInstId, CommTopo* topoType)
100 : {
101 2 : return pImpl->GetTopoType(netLayer, topoInstId, topoType);
102 : }
103 :
104 2 : HcclResult RankGraphV2::GetRanksByTopoInst(const uint32_t netLayer, const uint32_t topoInstId, uint32_t** ranks, uint32_t* rankNum)
105 : {
106 2 : return pImpl->GetRanksByTopoInst(netLayer, topoInstId, ranks, rankNum);
107 : }
108 :
109 1 : HcclResult RankGraphV2::GetEndpointNum(uint32_t netLayer, uint32_t topoInstId, uint32_t *num)
110 : {
111 1 : return pImpl->GetEndpointNum(netLayer, topoInstId, num);
112 : }
113 :
114 1 : HcclResult RankGraphV2::GetEndpointDesc(uint32_t netLayer, uint32_t topoInstId, uint32_t *descNum, EndpointDesc *endpointDesc)
115 : {
116 1 : return pImpl->GetEndpointDesc(netLayer, topoInstId, descNum, endpointDesc);
117 : }
118 :
119 0 : HcclResult RankGraphV2::GetEndpointInfo(uint32_t rankId, const EndpointDesc *endPointDesc, EndpointAttr endpointAttr, uint32_t infoLen, void *info)
120 : {
121 0 : return pImpl->GetEndpointInfo(rankId, endPointDesc, endpointAttr, infoLen, info);
122 : }
123 :
124 : }; // namespace hccl
|