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 NEW_TOPO_INFO_H
12 : #define NEW_TOPO_INFO_H
13 :
14 : #include <map>
15 : #include <vector>
16 : #include <unordered_set>
17 :
18 : #include "peer_info.h"
19 : #include "edge_info.h"
20 :
21 : namespace Hccl {
22 :
23 : constexpr u32 MAX_PEER_COUNT = 65;
24 : class TopoInfo {
25 : public:
26 63 : TopoInfo() {};
27 : std::string version;
28 : u32 peerCount{0};
29 : u32 edgeCount{0};
30 : std::vector<PeerInfo> peers;
31 : std::map<u32, std::vector<EdgeInfo>> edges;
32 : void Deserialize(const nlohmann::json& topoInfoJson);
33 : std::string Describe() const;
34 : void Dump() const;
35 : TopoInfo(BinaryStream& binaryStream);
36 : void GetBinStream(BinaryStream& binaryStream) const;
37 :
38 : private:
39 : void DeserializePeers(const nlohmann::json& topoInfoJson);
40 : void DeserializeEdges(const nlohmann::json& topoInfoJson);
41 : void VerifyEdges(EdgeInfo& edge);
42 : unordered_set<u32> idSet;
43 : };
44 : } // namespace Hccl
45 : #endif // NEW_TOPO_INFO_H
|