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 "topoinfo_ranktableParser_pub.h"
12 :
13 : #include <map>
14 : #include <vector>
15 : #include <string>
16 : #include <fstream>
17 : #include <algorithm>
18 : #include <unistd.h>
19 : #include <chrono>
20 : #include <iostream>
21 : #include <arpa/inet.h>
22 :
23 : #include "hccl_comm_pub.h"
24 : #include "topoinfo_ranktableStandard.h"
25 : #include "topoinfo_ranktableConcise.h"
26 : #include "topoinfo_ranktableHeterog.h"
27 : #include "config.h"
28 : #include "adapter_error_manager_pub.h"
29 : #include "json_utils.h"
30 :
31 : using namespace std;
32 : using namespace hccl;
33 :
34 0 : HcclResult CheckAverageDev([[maybe_unused]] u32 uDeviceNum, [[maybe_unused]] u32 uServerNum)
35 : {
36 0 : return HCCL_E_NOT_SUPPORT;
37 : }
38 :
39 1 : TopoInfoRanktableParser::TopoInfoRanktableParser(const std::string& rankTableM, const std::string& identify)
40 1 : : rankTableFile_(rankTableM),
41 1 : identify_(identify),
42 1 : statusCompleted_(false),
43 2 : uniqueInfoCheckPool_(static_cast<u32>(JsonUniqueInfoType::UNIQUE_INFO_NUM)),
44 4 : devMap_()
45 1 : {}
46 :
47 1 : TopoInfoRanktableParser::~TopoInfoRanktableParser() {}
48 :
49 0 : HcclResult TopoInfoRanktableParser::ReadFile([[maybe_unused]] const std::string& readFile)
50 : {
51 0 : return HCCL_E_NOT_SUPPORT;
52 : }
53 :
54 0 : HcclResult TopoInfoRanktableParser::LoadFile([[maybe_unused]] const std::string& file) { return HCCL_E_NOT_SUPPORT; }
55 :
56 0 : HcclResult TopoInfoRanktableParser::LoadRankTableString([[maybe_unused]] const std::string& string)
57 : {
58 0 : return HCCL_E_NOT_SUPPORT;
59 : }
60 :
61 0 : HcclResult TopoInfoRanktableParser::LoadConfigString([[maybe_unused]] const std::string& string)
62 : {
63 0 : return HCCL_E_NOT_SUPPORT;
64 : }
65 :
66 0 : HcclResult TopoInfoRanktableParser::LoadString([[maybe_unused]] const std::string& string)
67 : {
68 0 : return HCCL_E_NOT_SUPPORT;
69 : }
70 :
71 0 : HcclResult TopoInfoRanktableParser::GetClusterInfo([[maybe_unused]] RankTable_t& clusterInfo)
72 : {
73 0 : return HCCL_E_NOT_SUPPORT;
74 : }
75 0 : HcclResult TopoInfoRanktableParser::GetClusterInfo(
76 : [[maybe_unused]] hccl::HcclCommParams& params, [[maybe_unused]] hccl::RankTable_t& rankTable)
77 : {
78 0 : return HCCL_E_NOT_SUPPORT;
79 : }
80 :
81 0 : HcclResult TopoInfoRanktableParser::Init() { return HCCL_E_NOT_SUPPORT; }
82 :
83 0 : HcclResult TopoInfoRanktableParser::LoadFileInit([[maybe_unused]] std::string& rankTableM)
84 : {
85 0 : return HCCL_E_NOT_SUPPORT;
86 : }
87 :
88 0 : HcclResult TopoInfoRanktableParser::SetIsInterSuperPodRetryEnable([[maybe_unused]] bool isRetryEnable)
89 : {
90 0 : return HCCL_E_NOT_SUPPORT;
91 : }
92 :
93 0 : HcclResult TopoInfoRanktableParser::GetRanktableVersion([[maybe_unused]] std::string& version)
94 : {
95 0 : return HCCL_E_NOT_SUPPORT;
96 : }
97 :
98 0 : HcclResult TopoInfoRanktableParser::RefreshStatus() { return HCCL_E_NOT_SUPPORT; }
99 :
100 0 : bool TopoInfoRanktableParser::IsReady() const { return this->statusCompleted_; }
101 :
102 0 : HcclResult TopoInfoRanktableParser::GetJsonProperty(
103 : [[maybe_unused]] const nlohmann::json& obj, [[maybe_unused]] const char* propName,
104 : [[maybe_unused]] std::string& propValue, [[maybe_unused]] bool optionalProp) const
105 : {
106 0 : return HCCL_E_NOT_SUPPORT;
107 : }
108 :
109 0 : HcclResult TopoInfoRanktableParser::GetJsonProperty(
110 : [[maybe_unused]] const nlohmann::json& obj, [[maybe_unused]] const char* propName,
111 : [[maybe_unused]] nlohmann::json& propValue, [[maybe_unused]] bool optionalProp) const
112 : {
113 0 : return HCCL_E_NOT_SUPPORT;
114 : }
115 :
116 0 : HcclResult TopoInfoRanktableParser::GetJsonArrayMemberProperty(
117 : [[maybe_unused]] const nlohmann::json& obj, [[maybe_unused]] const u32 index, [[maybe_unused]] const char* propName,
118 : [[maybe_unused]] std::string& propValue, [[maybe_unused]] bool optionalProp) const
119 : {
120 0 : return HCCL_E_NOT_SUPPORT;
121 : }
122 :
123 0 : HcclResult TopoInfoRanktableParser::GetJsonArrayMemberProperty(
124 : [[maybe_unused]] const nlohmann::json& obj, [[maybe_unused]] const u32 index, [[maybe_unused]] const char* propName,
125 : [[maybe_unused]] u32& propValue, [[maybe_unused]] bool optionalProp) const
126 : {
127 0 : return HCCL_E_NOT_SUPPORT;
128 : }
129 :
130 0 : HcclResult TopoInfoRanktableParser::GetJsonArrayMemberProperty(
131 : [[maybe_unused]] const nlohmann::json& obj, [[maybe_unused]] const u32 index, [[maybe_unused]] const char* propName,
132 : [[maybe_unused]] nlohmann::json& propValue, [[maybe_unused]] bool optionalProp) const
133 : {
134 0 : return HCCL_E_NOT_SUPPORT;
135 : }
136 :
137 : /* 依据检查类型进行入参内容检查,并将检查选项转为strType带出以便后续信息打印 */
138 0 : HcclResult TopoInfoRanktableParser::CheckUniquePara(
139 : [[maybe_unused]] const JsonUniqueInfoType& type, [[maybe_unused]] const std::string& value,
140 : [[maybe_unused]] string& strType) const
141 : {
142 0 : return HCCL_E_NOT_SUPPORT;
143 : }
144 :
145 0 : HcclResult TopoInfoRanktableParser::CheckUniqueAndInsertPool(
146 : [[maybe_unused]] const JsonUniqueInfoType& type, [[maybe_unused]] const std::string& value,
147 : [[maybe_unused]] const JsonCheckOpType& opType)
148 : {
149 0 : return HCCL_E_NOT_SUPPORT;
150 : }
151 :
152 0 : void TopoInfoRanktableParser::GenerateServerIdx(
153 : [[maybe_unused]] const std::string& serverId, [[maybe_unused]] u32& serverIdx)
154 : {
155 0 : return;
156 : }
157 :
158 0 : void TopoInfoRanktableParser::GenerateSuperPodIdx(
159 : [[maybe_unused]] const std::string& superPodId, [[maybe_unused]] u32& superPodIdx)
160 : {
161 0 : return;
162 : }
163 :
164 0 : HcclResult TopoInfoRanktableParser::ConvertIpAddress(
165 : [[maybe_unused]] const std::string& ipStr, [[maybe_unused]] HcclIpAddress& ipAddr)
166 : {
167 0 : return HCCL_E_NOT_SUPPORT;
168 : }
|