LCOV - code coverage report
Current view: top level - legacy/ascend910/framework/common/src/topo/topo_device - topoinfo_detect_device.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 8.6 % 105 9
Test Date: 2026-08-04 10:52:23 Functions: 7.8 % 51 4

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

Generated by: LCOV version 2.0-1