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_HCOMM_GRAPH_H
12 : #define RANK_HCOMM_GRAPH_H
13 :
14 : #include "topoinfo_struct.h"
15 : #include "hccl/hccl_res.h"
16 : #include "hccl_independent_common.h"
17 : #include "hccl_common.h"
18 : #include "hccl_impl_pub.h"
19 : #include "hccl_rank_graph.h"
20 : #include "hccl_rankgraph.h"
21 :
22 : namespace hccl {
23 : class RankGraph {
24 : public:
25 : static constexpr uint32_t HCCL_NETLAYER_0 = 0;
26 : static constexpr uint32_t HCCL_NETLAYER_1 = 1;
27 : static constexpr uint32_t HCCL_NETLAYER_2 = 2;
28 :
29 1057 : RankGraph() = default;
30 1053 : virtual ~RankGraph() = default;
31 : virtual HcclResult
32 0 : Init([[maybe_unused]] const RankTable_t& rankTable, [[maybe_unused]] const HcclTopoAttr& topoAttr)
33 : {
34 0 : return HCCL_SUCCESS;
35 : };
36 0 : virtual HcclResult GetRankId([[maybe_unused]] uint32_t* rank) { return HCCL_E_NOT_SUPPORT; };
37 0 : virtual HcclResult GetRankSize([[maybe_unused]] uint32_t* rankSize) { return HCCL_E_NOT_SUPPORT; };
38 0 : virtual HcclResult GetDevicePort([[maybe_unused]] const uint32_t rank, [[maybe_unused]] uint32_t* devPort)
39 : {
40 0 : return HCCL_E_NOT_SUPPORT;
41 : };
42 0 : virtual HcclResult GetListenPort(
43 : [[maybe_unused]] const uint32_t rank, [[maybe_unused]] uint32_t* listenPort,
44 : [[maybe_unused]] EndpointLocType locType)
45 : {
46 0 : return HCCL_E_NOT_SUPPORT;
47 : };
48 : virtual HcclResult GetRankGraphInfo(GraphType type, void** graph, uint32_t* len) = 0;
49 : virtual HcclResult
50 : GetLinks(uint32_t netLayer, uint32_t srcRank, uint32_t dstRank, CommLink** linkList, uint32_t* listSize)
51 : = 0;
52 : virtual HcclResult GetNetLayers(uint32_t** netLayers, uint32_t* netLayerNum) = 0;
53 0 : virtual HcclResult GetHeterogMode([[maybe_unused]] HcclHeterogMode* mode) const { return HCCL_SUCCESS; }
54 : virtual HcclResult GetInstTopoTypeByNetLayer(uint32_t netLayer, CommTopo* topoType) = 0;
55 : virtual HcclResult GetInstSizeByNetLayer(uint32_t netLayer, uint32_t* rankNum) = 0;
56 : virtual HcclResult GetInstRanksByNetLayer(uint32_t netLayer, uint32_t** rankList, uint32_t* rankNum) = 0;
57 : virtual HcclResult GetInstSizeListByNetLayer(uint32_t netLayer, uint32_t** instSizeList, uint32_t* listSize) = 0;
58 : virtual HcclResult GetDeviceId(uint32_t rankId, uint32_t* deviceId) = 0;
59 : virtual HcclResult GetEndpointInfo(
60 : uint32_t rankId, const EndpointDesc* endPointDesc, EndpointAttr endpointAttr, uint32_t infoLen, void* info)
61 : = 0;
62 : };
63 : } // namespace hccl
64 : #endif
|