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_detect.h"
12 : #include <string>
13 : #include "adapter_rts_common.h"
14 : #include "hccl_whitelist.h"
15 : #include "hccl_socket.h"
16 : #include "sal_pub.h"
17 : #include "device_capacity.h"
18 : #include "preempt_port_manager.h"
19 :
20 : using namespace std;
21 : namespace hccl {
22 : UniversalConcurrentMap<u32, volatile u32> TopoInfoDetect::g_topoExchangeServerStatus_;
23 :
24 2 : TopoInfoDetect::TopoInfoDetect()
25 2 : : deviceLogicID_(INVALID_INT),
26 2 : localRankInfo_(),
27 2 : clusterTopoInfo_(),
28 2 : isInterSuperPodRetryEnable_(GetExternalInputInterSuperPodRetryEnable())
29 2 : {}
30 :
31 2 : TopoInfoDetect::~TopoInfoDetect() {}
32 :
33 : HcclResult
34 0 : TopoInfoDetect::GetServerConnections([[maybe_unused]] std::map<u32, std::shared_ptr<HcclSocket>>& connectSockets)
35 : {
36 0 : return HCCL_E_NOT_SUPPORT;
37 : }
38 :
39 0 : HcclResult TopoInfoDetect::GetAgentListenSocket([[maybe_unused]] HcclSocketPortConfig& commPortConfig)
40 : {
41 0 : return HCCL_E_NOT_SUPPORT;
42 : }
43 :
44 0 : HcclResult TopoInfoDetect::GetAgentConnection([[maybe_unused]] std::shared_ptr<HcclSocket>& connectSocket)
45 : {
46 0 : return HCCL_E_NOT_SUPPORT;
47 : }
48 :
49 0 : HcclResult TopoInfoDetect::SendGroupLeaderPort(
50 : [[maybe_unused]] std::shared_ptr<HcclSocket>& connectSocket, [[maybe_unused]] HcclRankHandle& rankHandle)
51 : {
52 0 : return HCCL_E_NOT_SUPPORT;
53 : }
54 :
55 0 : void TopoInfoDetect::SetupTopoGroupLeader(
56 : [[maybe_unused]] s32 devicePhysicID, [[maybe_unused]] s32 deviceLogicID, [[maybe_unused]] HcclIpAddress hostIP,
57 : [[maybe_unused]] u32 hostPort, [[maybe_unused]] vector<HcclIpAddress> whitelist,
58 : [[maybe_unused]] HcclNetDevCtx netDevCtx, [[maybe_unused]] std::shared_ptr<HcclSocket> listenSocket,
59 : [[maybe_unused]] std::shared_ptr<HcclSocket> grpLeaderToRoot, [[maybe_unused]] bool isMasterInfo)
60 : {
61 0 : return;
62 : }
63 :
64 0 : void TopoInfoDetect::SetupTopoExchangeServer(
65 : [[maybe_unused]] s32 devicePhysicID, [[maybe_unused]] s32 deviceLogicID, [[maybe_unused]] HcclIpAddress hostIP,
66 : [[maybe_unused]] u32 hostPort, [[maybe_unused]] vector<HcclIpAddress> whitelist,
67 : [[maybe_unused]] HcclNetDevCtx netDevCtx, [[maybe_unused]] std::shared_ptr<HcclSocket> listenSocket,
68 : [[maybe_unused]] bool isMasterInfo)
69 : {
70 0 : return;
71 : }
72 0 : HcclResult TopoInfoDetect::SetupServerByMasterInfo(
73 : [[maybe_unused]] const HcclIpAddress& masterIP, [[maybe_unused]] u32 masterPort,
74 : [[maybe_unused]] const HcclRootHandle& rootInfo)
75 : {
76 0 : return HCCL_E_NOT_SUPPORT;
77 : }
78 :
79 0 : HcclResult TopoInfoDetect::SetupServer([[maybe_unused]] HcclRootHandle& rootInfo) { return HCCL_E_NOT_SUPPORT; }
80 :
81 1 : HcclResult TopoInfoDetect::GroupLeaderListen(
82 : [[maybe_unused]] HcclRankHandle& rankHandle, [[maybe_unused]] vector<HcclIpAddress>& whitelist)
83 : {
84 1 : return HCCL_E_NOT_SUPPORT;
85 : }
86 :
87 0 : HcclResult TopoInfoDetect::GroupLeaderAccept(
88 : [[maybe_unused]] HcclRankHandle& grpLeaderInfo, [[maybe_unused]] vector<HcclIpAddress> whitelist,
89 : [[maybe_unused]] std::shared_ptr<HcclSocket> grpLeaderToRoot)
90 : {
91 0 : return HCCL_E_NOT_SUPPORT;
92 : }
93 :
94 0 : HcclResult TopoInfoDetect::GenerateRootInfo(
95 : [[maybe_unused]] const HcclIpAddress& hostIP, [[maybe_unused]] u32 hostPort, [[maybe_unused]] u32 devicePhysicID,
96 : [[maybe_unused]] HcclRootHandle& rootInfo)
97 : {
98 0 : return HCCL_E_NOT_SUPPORT;
99 : }
100 :
101 0 : HcclResult TopoInfoDetect::CalcGroupSizeAndRank(
102 : [[maybe_unused]] const u32 nRanks, [[maybe_unused]] const u32 rank, [[maybe_unused]] u32& groupSize,
103 : [[maybe_unused]] u32& groupRank)
104 : {
105 0 : return HCCL_E_NOT_SUPPORT;
106 : }
107 :
108 0 : HcclResult TopoInfoDetect::SetupGroupMember(
109 : [[maybe_unused]] u32 rankSize, [[maybe_unused]] u32 myrank, [[maybe_unused]] const HcclRootHandle& rootInfo)
110 : {
111 0 : return HCCL_E_NOT_SUPPORT;
112 : }
113 :
114 0 : HcclResult TopoInfoDetect::TeardownServer() { return HCCL_E_NOT_SUPPORT; }
115 :
116 0 : HcclResult TopoInfoDetect::WaitTopoExchangeServerCompelte([[maybe_unused]] u32 idx) const { return HCCL_E_NOT_SUPPORT; }
117 :
118 0 : HcclResult TopoInfoDetect::PrepareHandle(
119 : [[maybe_unused]] HcclRankHandle& rankHandle, [[maybe_unused]] std::vector<HcclIpAddress>& whitelist)
120 : {
121 0 : return HCCL_E_NOT_SUPPORT;
122 : }
123 :
124 0 : HcclResult TopoInfoDetect::SetupAgent(
125 : [[maybe_unused]] u32 rankSize, [[maybe_unused]] u32 myrank, [[maybe_unused]] const HcclRootHandle& rootInfo,
126 : [[maybe_unused]] const HcclRankHandle& rankHandle, [[maybe_unused]] const CommConfig& commConfig)
127 : {
128 0 : return HCCL_E_NOT_SUPPORT;
129 : }
130 :
131 0 : HcclResult TopoInfoDetect::SetupRank([[maybe_unused]] std::shared_ptr<HcclSocket>& agentConnRoot)
132 : {
133 0 : return HCCL_E_NOT_SUPPORT;
134 : }
135 :
136 0 : HcclResult TopoInfoDetect::TeardownAgent() { return HCCL_E_NOT_SUPPORT; }
137 :
138 0 : HcclResult TopoInfoDetect::SetupAgentByMasterInfo(
139 : [[maybe_unused]] HcclIpAddress& localHostIp, [[maybe_unused]] const HcclRootHandle& rootInfo)
140 : {
141 0 : return HCCL_E_NOT_SUPPORT;
142 : }
143 :
144 0 : HcclResult TopoInfoDetect::WaitComplete([[maybe_unused]] const HcclRootHandle& rootInfo) { return HCCL_E_NOT_SUPPORT; }
145 :
146 0 : HcclResult TopoInfoDetect::Teardown() { return HCCL_E_NOT_SUPPORT; }
147 :
148 0 : HcclResult TopoInfoDetect::ReadHostSocketWhitelist([[maybe_unused]] vector<HcclIpAddress>& whitelist) const
149 : {
150 0 : return HCCL_E_NOT_SUPPORT;
151 : }
152 :
153 0 : HcclResult TopoInfoDetect::GetAllHostIfInfos(
154 : [[maybe_unused]] vector<pair<string, HcclIpAddress>>& ifInfos, [[maybe_unused]] u32 devPhyId) const
155 : {
156 0 : return HCCL_E_NOT_SUPPORT;
157 : }
158 :
159 0 : HcclResult TopoInfoDetect::GetAllValidHostIfInfos(
160 : [[maybe_unused]] const vector<HcclIpAddress>& whitelist,
161 : [[maybe_unused]] vector<pair<string, HcclIpAddress>>& ifInfos, [[maybe_unused]] u32 devPhyId)
162 : {
163 0 : return HCCL_E_NOT_SUPPORT;
164 : }
165 :
166 0 : HcclResult TopoInfoDetect::GetRootHostIP(
167 : [[maybe_unused]] const vector<HcclIpAddress>& whitelist, [[maybe_unused]] HcclIpAddress& ip,
168 : [[maybe_unused]] u32 devPhyId)
169 : {
170 0 : return HCCL_E_NOT_SUPPORT;
171 : }
172 :
173 0 : HcclResult TopoInfoDetect::GetGroupLeader([[maybe_unused]] HcclRankHandle& rankHandle) { return HCCL_E_NOT_SUPPORT; }
174 :
175 0 : HcclResult TopoInfoDetect::SetIsInterSuperPodRetryEnable([[maybe_unused]] bool isRetry) { return HCCL_E_NOT_SUPPORT; }
176 :
177 0 : HcclResult TopoInfoDetect::StartRootNetwork(
178 : [[maybe_unused]] const HcclIpAddress& hostIP, [[maybe_unused]] u32& usePort,
179 : [[maybe_unused]] const std::vector<HcclSocketPortRange>& portRanges)
180 : {
181 0 : return HCCL_E_NOT_SUPPORT;
182 : }
183 :
184 1 : HcclResult TopoInfoDetect::StartGroupLeaderNetwork(
185 : [[maybe_unused]] const vector<HcclIpAddress>& whitelist, [[maybe_unused]] const HcclIpAddress& hostIP,
186 : [[maybe_unused]] u32& bindPort, [[maybe_unused]] const std::vector<HcclSocketPortRange>& portRanges)
187 : {
188 1 : return HCCL_E_NOT_SUPPORT;
189 : }
190 :
191 0 : HcclResult TopoInfoDetect::AddSocketWhiteList(
192 : [[maybe_unused]] u32 port, [[maybe_unused]] const vector<HcclIpAddress>& whitelist) const
193 : {
194 0 : return HCCL_E_NOT_SUPPORT;
195 : }
196 :
197 0 : HcclResult TopoInfoDetect::StartNetwork([[maybe_unused]] HcclIpAddress& hostIP, [[maybe_unused]] bool bInitDevNic)
198 : {
199 0 : return HCCL_E_NOT_SUPPORT;
200 : }
201 :
202 0 : HcclResult TopoInfoDetect::StopNetwork([[maybe_unused]] HcclIpAddress& hostIP, [[maybe_unused]] bool bInitDevNic)
203 : {
204 0 : return HCCL_E_NOT_SUPPORT;
205 : }
206 :
207 0 : HcclResult TopoInfoDetect::FilterDevIPs(
208 : [[maybe_unused]] std::vector<HcclIpAddress>& sourceDeviceIPs,
209 : [[maybe_unused]] std::vector<HcclIpAddress>& targetDeviceIPs) const
210 : {
211 0 : return HCCL_E_NOT_SUPPORT;
212 : }
213 :
214 0 : HcclResult TopoInfoDetect::PreemptDeviceNicPort(
215 : [[maybe_unused]] const u32 devPhyId, [[maybe_unused]] const s32 devLogicId,
216 : [[maybe_unused]] const HcclIpAddress& deviceIp, [[maybe_unused]] u32& usePort)
217 : {
218 0 : return HCCL_E_NOT_SUPPORT;
219 : }
220 :
221 0 : HcclResult TopoInfoDetect::PreemptDeviceVnicPort([[maybe_unused]] HcclBasicRankInfo& localRankInfo)
222 : {
223 0 : return HCCL_E_NOT_SUPPORT;
224 : }
225 :
226 0 : HcclResult TopoInfoDetect::PreemptBackupDeviceNicPort(
227 : [[maybe_unused]] const u32 devPhyId, [[maybe_unused]] const s32 devLogicId,
228 : [[maybe_unused]] const HcclIpAddress& deviceIp, [[maybe_unused]] const HcclIpAddress& backupDeviceIp,
229 : [[maybe_unused]] u32& usePort)
230 : {
231 0 : return HCCL_E_NOT_SUPPORT;
232 : }
233 :
234 0 : HcclResult TopoInfoDetect::GetDeviceBackupNicInfo([[maybe_unused]] HcclBasicRankInfo& localRankInfo)
235 : {
236 0 : return HCCL_E_NOT_SUPPORT;
237 : }
238 :
239 0 : HcclResult TopoInfoDetect::GenerateLocalRankInfo(
240 : [[maybe_unused]] u32 rankSize, [[maybe_unused]] u32 rankID, [[maybe_unused]] HcclBasicRankInfo& localRankInfo)
241 : {
242 0 : return HCCL_E_NOT_SUPPORT;
243 : }
244 :
245 0 : HcclResult TopoInfoDetect::GetSuperPodInfo(
246 : [[maybe_unused]] s32 deviceLogicId, [[maybe_unused]] std::string& superPodId, [[maybe_unused]] u32& superDeviceId)
247 : {
248 0 : return HCCL_E_NOT_SUPPORT;
249 : }
250 :
251 0 : HcclResult TopoInfoDetect::GetCluterInfo([[maybe_unused]] RankTable_t& clusterInfo) { return HCCL_E_NOT_SUPPORT; }
252 0 : HcclResult TopoInfoDetect::GetRankId(u32& rankId)
253 : {
254 0 : rankId = identifierNum_;
255 0 : return HCCL_SUCCESS;
256 : }
257 :
258 0 : HcclResult TopoInfoDetect::GetLocalRankInfo([[maybe_unused]] HcclBasicRankInfo& rankInfo) { return HCCL_E_NOT_SUPPORT; }
259 :
260 0 : void TopoInfoDetect::SetBootstrapHostIP(HcclIpAddress& ip) { bootstrapHostIP_ = ip; }
261 :
262 0 : HcclIpAddress TopoInfoDetect::GetBootstrapHostIP() const { return bootstrapHostIP_; }
263 0 : HcclResult TopoInfoDetect::TransformRankTableStr(
264 : [[maybe_unused]] const RankTable_t& clusterInfo, [[maybe_unused]] string& ranktableStr)
265 : {
266 0 : return HCCL_E_NOT_SUPPORT;
267 : }
268 0 : HcclResult TopoInfoDetect::TransformDeviceList(
269 : [[maybe_unused]] const RankTable_t& clusterInfo, [[maybe_unused]] vector<RankInfo_t>& tmpRankList,
270 : [[maybe_unused]] nlohmann::json& perServerJson, [[maybe_unused]] u32 serverIndex)
271 : {
272 0 : return HCCL_E_NOT_SUPPORT;
273 : }
274 0 : HcclResult TopoInfoDetect::Struct2JsonRankTable(
275 : [[maybe_unused]] const RankTable_t& clusterInfo, [[maybe_unused]] nlohmann::json& ClusterJson)
276 : {
277 0 : return HCCL_E_NOT_SUPPORT;
278 : }
279 :
280 0 : HcclResult TopoInfoDetect::TransformSuperPodList(
281 : [[maybe_unused]] const std::vector<RankInfo_t>& rankInfo, [[maybe_unused]] nlohmann::json& superPodListJson) const
282 : {
283 0 : return HCCL_E_NOT_SUPPORT;
284 : }
285 : } // namespace hccl
|