LCOV - code coverage report
Current view: top level - coll_communicator_mgr/rank_graph/topo_info - edge_info.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 2 2
Test Date: 2026-08-18 17:47:01 Functions: 100.0 % 2 2

            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 EDGE_INFO_H
      12              : #define EDGE_INFO_H
      13              : 
      14              : #include <string>
      15              : #include <unordered_map>
      16              : #include <set>
      17              : #include "nlohmann/json.hpp"
      18              : #include "types.h"
      19              : #include "topo_common_types.h"
      20              : #include "ip_address.h"
      21              : 
      22              : namespace Hccl {
      23              : 
      24              : constexpr unsigned int MAX_VALUE_LEVEL = 7;
      25              : constexpr u32 PORT_MAX_LENGTH = 32;
      26              : constexpr u32 MAX_PORTS_SIZE = 64;
      27              : 
      28              : class EdgeInfo {
      29              : public:
      30          198 :     EdgeInfo() {};
      31              :     EdgeInfo(BinaryStream& binaryStream);
      32          941 :     ~EdgeInfo() {};
      33              : 
      34              :     u32 netLayer{0};
      35              :     LinkType linkType;
      36              :     TopoType topoType{TopoType::CLOS};
      37              :     u32 topoInstId{0};
      38              :     std::set<LinkProtocol> protocols;
      39              : 
      40              :     u32 localA{0};
      41              :     std::set<std::string> localAPorts;
      42              :     u32 localB{0};
      43              :     std::set<std::string> localBPorts;
      44              :     AddrPosition position;
      45              : 
      46              :     bool operator==(const EdgeInfo& other) const;
      47              :     void Deserialize(const nlohmann::json& edgeInfoJson);
      48              :     LinkProtocol GetLinkProtocol(std::string str) const;
      49              :     TopoType GetTopoType(std::string topoTypeStr) const;
      50              :     LinkType GetLinkType(std::string linkTypeStr) const;
      51              :     AddrPosition GetAddrPosition(std::string str) const;
      52              :     std::string Describe() const;
      53              :     void GetBinStream(BinaryStream& binaryStream) const;
      54              : 
      55              : private:
      56              :     const static std::unordered_map<std::string, LinkProtocol> strToLinkProtocol;
      57              :     const static std::unordered_map<std::string, TopoType> strToTopoType;
      58              :     const static std::unordered_map<std::string, LinkType> strToLinkType;
      59              :     const static std::unordered_map<std::string, AddrPosition> strToAddrPosition;
      60              :     bool CompareEndpoints(const EdgeInfo& other) const;
      61              :     void DeserializeProtocol(const nlohmann::json& edgeInfoJson);
      62              :     void DeserializeEndpoint(const nlohmann::json& edgeInfoJson);
      63              :     void DeserializePort(const nlohmann::json& edgeInfoJson, std::string propName, std::set<std::string>& ports);
      64              :     std::string DescribePorts(std::set<std::string> ports) const;
      65              : };
      66              : } // namespace Hccl
      67              : 
      68              : #endif // EDGE_INFO_H
        

Generated by: LCOV version 2.0-1