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 : #ifndef RANK_GRAPH_INTERFACE_H
12 : #define RANK_GRAPH_INTERFACE_H
13 :
14 : #include "hccl_rank_graph.h"
15 : #include "hccl_types.h"
16 : #include "rank_gph.h"
17 :
18 : namespace Hccl {
19 :
20 : class IRankGraph {
21 : public:
22 197 : IRankGraph(void* rankGraphPtr) : rankGraphPtr_(rankGraphPtr) {}
23 :
24 390 : virtual ~IRankGraph() = default;
25 :
26 : HcclResult GetRankId(uint32_t* rank);
27 : HcclResult GetRankSize(uint32_t* rankSize);
28 : HcclResult GetDevicePort(const uint32_t rank, uint32_t* devPort);
29 : HcclResult GetHostPort(const uint32_t rank, uint32_t* hostPort);
30 : HcclResult GetLinks(uint32_t netLayer, uint32_t srcRank, uint32_t dstRank, CommLink** linkList, uint32_t* listSize);
31 : HcclResult GetRankGraphInfo(void** graph, uint32_t* len);
32 : HcclResult GetNetLayers(uint32_t** netLayers, uint32_t* netLayerNum);
33 : HcclResult GetInstTopoTypeByNetLayer(uint32_t netLayer, CommTopo* topoType);
34 : HcclResult GetInstSizeByNetLayer(uint32_t netLayer, uint32_t* rankNum);
35 : HcclResult GetInstRanksByNetLayer(uint32_t netLayer, uint32_t** rankList, uint32_t* rankNum);
36 : HcclResult GetInstSizeListByNetLayer(uint32_t netLayer, uint32_t** instSizeList, uint32_t* listSize);
37 : HcclResult GetTopoInstsByLayer(uint32_t netLayer, uint32_t** topoInsts, uint32_t* topoInstNum);
38 : HcclResult GetTopoType(const uint32_t netLayer, const uint32_t topoInstId, CommTopo* topoType);
39 : HcclResult
40 : GetRanksByTopoInst(const uint32_t netLayer, const uint32_t topoInstId, uint32_t** ranks, uint32_t* rankNum);
41 : HcclResult GetEndpointNum(uint32_t netLayer, uint32_t topoInstId, uint32_t* num);
42 : HcclResult GetEndpointDesc(uint32_t netLayer, uint32_t topoInstId, uint32_t* descNum, EndpointDesc* endpointDesc);
43 : HcclResult GetEndpointInfo(
44 : uint32_t rankId, const EndpointDesc* endPointDesc, EndpointAttr endpointAttr, uint32_t infoLen, void* info);
45 : HcclResult GetDeviceId(uint32_t rankId, uint32_t* deviceId);
46 :
47 : private:
48 : void* rankGraphPtr_;
49 : std::vector<uint32_t> instSizeVec_;
50 : std::vector<uint32_t> rankListVec_;
51 : std::vector<uint32_t> netLayersVec_;
52 : std::vector<CommLink> linkListVec_;
53 : std::vector<uint32_t> topoInstsVec_;
54 : std::vector<uint32_t> ranksVec_;
55 : };
56 :
57 : } // namespace Hccl
58 :
59 : #endif // RANK_GRAPH_INTERFACE_H
|