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