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 0 : HcclResult TopoInfoDetect::GetServerConnections(std::map<u32, std::shared_ptr<HcclSocket>>& connectSockets)
34 : {
35 0 : return HCCL_E_NOT_SUPPORT;
36 : }
37 :
38 0 : HcclResult TopoInfoDetect::GetAgentListenSocket(HcclSocketPortConfig& commPortConfig) { return HCCL_E_NOT_SUPPORT; }
39 :
40 0 : HcclResult TopoInfoDetect::GetAgentConnection(std::shared_ptr<HcclSocket>& connectSocket) { return HCCL_E_NOT_SUPPORT; }
41 :
42 0 : HcclResult TopoInfoDetect::SendGroupLeaderPort(std::shared_ptr<HcclSocket>& connectSocket, HcclRankHandle& rankHandle)
43 : {
44 0 : return HCCL_E_NOT_SUPPORT;
45 : }
46 :
47 0 : void TopoInfoDetect::SetupTopoGroupLeader(
48 : s32 devicePhysicID, s32 deviceLogicID, HcclIpAddress hostIP, u32 hostPort, vector<HcclIpAddress> whitelist,
49 : HcclNetDevCtx netDevCtx, std::shared_ptr<HcclSocket> listenSocket, std::shared_ptr<HcclSocket> grpLeaderToRoot,
50 : bool isMasterInfo)
51 : {
52 0 : return;
53 : }
54 :
55 0 : void TopoInfoDetect::SetupTopoExchangeServer(
56 : s32 devicePhysicID, s32 deviceLogicID, HcclIpAddress hostIP, u32 hostPort, vector<HcclIpAddress> whitelist,
57 : HcclNetDevCtx netDevCtx, std::shared_ptr<HcclSocket> listenSocket, bool isMasterInfo)
58 : {
59 0 : return;
60 : }
61 : HcclResult
62 0 : TopoInfoDetect::SetupServerByMasterInfo(const HcclIpAddress& masterIP, u32 masterPort, const HcclRootHandle& rootInfo)
63 : {
64 0 : return HCCL_E_NOT_SUPPORT;
65 : }
66 :
67 0 : HcclResult TopoInfoDetect::SetupServer(HcclRootHandle& rootInfo) { return HCCL_E_NOT_SUPPORT; }
68 :
69 1 : HcclResult TopoInfoDetect::GroupLeaderListen(HcclRankHandle& rankHandle, vector<HcclIpAddress>& whitelist)
70 : {
71 1 : return HCCL_E_NOT_SUPPORT;
72 : }
73 :
74 0 : HcclResult TopoInfoDetect::GroupLeaderAccept(
75 : HcclRankHandle& grpLeaderInfo, vector<HcclIpAddress> whitelist, std::shared_ptr<HcclSocket> grpLeaderToRoot)
76 : {
77 0 : return HCCL_E_NOT_SUPPORT;
78 : }
79 :
80 0 : HcclResult TopoInfoDetect::GenerateRootInfo(
81 : const HcclIpAddress& hostIP, u32 hostPort, u32 devicePhysicID, HcclRootHandle& rootInfo)
82 : {
83 0 : return HCCL_E_NOT_SUPPORT;
84 : }
85 :
86 0 : HcclResult TopoInfoDetect::CalcGroupSizeAndRank(const u32 nRanks, const u32 rank, u32& groupSize, u32& groupRank)
87 : {
88 0 : return HCCL_E_NOT_SUPPORT;
89 : }
90 :
91 0 : HcclResult TopoInfoDetect::SetupGroupMember(u32 rankSize, u32 myrank, const HcclRootHandle& rootInfo)
92 : {
93 0 : return HCCL_E_NOT_SUPPORT;
94 : }
95 :
96 0 : HcclResult TopoInfoDetect::TeardownServer() { return HCCL_E_NOT_SUPPORT; }
97 :
98 0 : HcclResult TopoInfoDetect::WaitTopoExchangeServerCompelte(u32 idx) const { return HCCL_E_NOT_SUPPORT; }
99 :
100 0 : HcclResult TopoInfoDetect::PrepareHandle(HcclRankHandle& rankHandle, std::vector<HcclIpAddress>& whitelist)
101 : {
102 0 : return HCCL_E_NOT_SUPPORT;
103 : }
104 :
105 0 : HcclResult TopoInfoDetect::SetupAgent(
106 : u32 rankSize, u32 myrank, const HcclRootHandle& rootInfo, const HcclRankHandle& rankHandle,
107 : const CommConfig& commConfig)
108 : {
109 0 : return HCCL_E_NOT_SUPPORT;
110 : }
111 :
112 0 : HcclResult TopoInfoDetect::SetupRank(std::shared_ptr<HcclSocket>& agentConnRoot) { return HCCL_E_NOT_SUPPORT; }
113 :
114 0 : HcclResult TopoInfoDetect::TeardownAgent() { return HCCL_E_NOT_SUPPORT; }
115 :
116 0 : HcclResult TopoInfoDetect::SetupAgentByMasterInfo(HcclIpAddress& localHostIp, const HcclRootHandle& rootInfo)
117 : {
118 0 : return HCCL_E_NOT_SUPPORT;
119 : }
120 :
121 0 : HcclResult TopoInfoDetect::WaitComplete(const HcclRootHandle& rootInfo) { return HCCL_E_NOT_SUPPORT; }
122 :
123 0 : HcclResult TopoInfoDetect::Teardown() { return HCCL_E_NOT_SUPPORT; }
124 :
125 0 : HcclResult TopoInfoDetect::ReadHostSocketWhitelist(vector<HcclIpAddress>& whitelist) const
126 : {
127 0 : return HCCL_E_NOT_SUPPORT;
128 : }
129 :
130 0 : HcclResult TopoInfoDetect::GetAllHostIfInfos(vector<pair<string, HcclIpAddress>>& ifInfos, u32 devPhyId) const
131 : {
132 0 : return HCCL_E_NOT_SUPPORT;
133 : }
134 :
135 0 : HcclResult TopoInfoDetect::GetAllValidHostIfInfos(
136 : const vector<HcclIpAddress>& whitelist, vector<pair<string, HcclIpAddress>>& ifInfos, u32 devPhyId)
137 : {
138 0 : return HCCL_E_NOT_SUPPORT;
139 : }
140 :
141 0 : HcclResult TopoInfoDetect::GetRootHostIP(const vector<HcclIpAddress>& whitelist, HcclIpAddress& ip, u32 devPhyId)
142 : {
143 0 : return HCCL_E_NOT_SUPPORT;
144 : }
145 :
146 0 : HcclResult TopoInfoDetect::GetGroupLeader(HcclRankHandle& rankHandle) { return HCCL_E_NOT_SUPPORT; }
147 :
148 0 : HcclResult TopoInfoDetect::SetIsInterSuperPodRetryEnable(bool isRetry) { return HCCL_E_NOT_SUPPORT; }
149 :
150 0 : HcclResult TopoInfoDetect::StartRootNetwork(
151 : const HcclIpAddress& hostIP, u32& usePort, const std::vector<HcclSocketPortRange>& portRanges)
152 : {
153 0 : return HCCL_E_NOT_SUPPORT;
154 : }
155 :
156 1 : HcclResult TopoInfoDetect::StartGroupLeaderNetwork(
157 : const vector<HcclIpAddress>& whitelist, const HcclIpAddress& hostIP, u32& bindPort,
158 : const std::vector<HcclSocketPortRange>& portRanges)
159 : {
160 1 : return HCCL_E_NOT_SUPPORT;
161 : }
162 :
163 0 : HcclResult TopoInfoDetect::AddSocketWhiteList(u32 port, const vector<HcclIpAddress>& whitelist) const
164 : {
165 0 : return HCCL_E_NOT_SUPPORT;
166 : }
167 :
168 0 : HcclResult TopoInfoDetect::StartNetwork(HcclIpAddress& hostIP, bool bInitDevNic) { return HCCL_E_NOT_SUPPORT; }
169 :
170 0 : HcclResult TopoInfoDetect::StopNetwork(HcclIpAddress& hostIP, bool bInitDevNic) { return HCCL_E_NOT_SUPPORT; }
171 :
172 0 : HcclResult TopoInfoDetect::FilterDevIPs(
173 : std::vector<HcclIpAddress>& sourceDeviceIPs, std::vector<HcclIpAddress>& targetDeviceIPs) const
174 : {
175 0 : return HCCL_E_NOT_SUPPORT;
176 : }
177 :
178 0 : HcclResult TopoInfoDetect::PreemptDeviceNicPort(
179 : const u32 devPhyId, const s32 devLogicId, const HcclIpAddress& deviceIp, u32& usePort)
180 : {
181 0 : return HCCL_E_NOT_SUPPORT;
182 : }
183 :
184 0 : HcclResult TopoInfoDetect::PreemptDeviceVnicPort(HcclBasicRankInfo& localRankInfo) { return HCCL_E_NOT_SUPPORT; }
185 :
186 0 : HcclResult TopoInfoDetect::PreemptBackupDeviceNicPort(
187 : const u32 devPhyId, const s32 devLogicId, const HcclIpAddress& deviceIp, const HcclIpAddress& backupDeviceIp,
188 : u32& usePort)
189 : {
190 0 : return HCCL_E_NOT_SUPPORT;
191 : }
192 :
193 0 : HcclResult TopoInfoDetect::GetDeviceBackupNicInfo(HcclBasicRankInfo& localRankInfo) { return HCCL_E_NOT_SUPPORT; }
194 :
195 0 : HcclResult TopoInfoDetect::GenerateLocalRankInfo(u32 rankSize, u32 rankID, HcclBasicRankInfo& localRankInfo)
196 : {
197 0 : return HCCL_E_NOT_SUPPORT;
198 : }
199 :
200 0 : HcclResult TopoInfoDetect::GetSuperPodInfo(s32 deviceLogicId, std::string& superPodId, u32& superDeviceId)
201 : {
202 0 : return HCCL_E_NOT_SUPPORT;
203 : }
204 :
205 0 : HcclResult TopoInfoDetect::GetCluterInfo(RankTable_t& clusterInfo) { return HCCL_E_NOT_SUPPORT; }
206 0 : HcclResult TopoInfoDetect::GetRankId(u32& rankId)
207 : {
208 0 : rankId = identifierNum_;
209 0 : return HCCL_SUCCESS;
210 : }
211 :
212 0 : HcclResult TopoInfoDetect::GetLocalRankInfo(HcclBasicRankInfo& rankInfo) { return HCCL_E_NOT_SUPPORT; }
213 :
214 0 : void TopoInfoDetect::SetBootstrapHostIP(HcclIpAddress& ip) { bootstrapHostIP_ = ip; }
215 :
216 0 : HcclIpAddress TopoInfoDetect::GetBootstrapHostIP() const { return bootstrapHostIP_; }
217 0 : HcclResult TopoInfoDetect::TransformRankTableStr(const RankTable_t& clusterInfo, string& ranktableStr)
218 : {
219 0 : return HCCL_E_NOT_SUPPORT;
220 : }
221 0 : HcclResult TopoInfoDetect::TransformDeviceList(
222 : const RankTable_t& clusterInfo, vector<RankInfo_t>& tmpRankList, nlohmann::json& perServerJson, u32 serverIndex)
223 : {
224 0 : return HCCL_E_NOT_SUPPORT;
225 : }
226 0 : HcclResult TopoInfoDetect::Struct2JsonRankTable(const RankTable_t& clusterInfo, nlohmann::json& ClusterJson)
227 : {
228 0 : return HCCL_E_NOT_SUPPORT;
229 : }
230 :
231 : HcclResult
232 0 : TopoInfoDetect::TransformSuperPodList(const std::vector<RankInfo_t>& rankInfo, nlohmann::json& superPodListJson) const
233 : {
234 0 : return HCCL_E_NOT_SUPPORT;
235 : }
236 : } // namespace hccl
|