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 UPDATER_FOR_64_PLUS_1_H
12 : #define UPDATER_FOR_64_PLUS_1_H
13 :
14 : #include <string>
15 : #include <memory>
16 : #include <unordered_map>
17 : #include <set>
18 : #include "rank_table_info.h"
19 : #include "rank_gph.h"
20 : #include "phy_topo.h"
21 :
22 : namespace Hccl {
23 :
24 : constexpr LocalId DEVICE_NUM_PER_AXIS = 8;
25 : constexpr LocalId DEVICE_HALF_NUM_PER_AXIS = 4;
26 : constexpr u32 BACKUP_TO_PLANE_ADDR_NUM = 4;
27 : constexpr u32 BACKUP_PLANE_NUM = 4;
28 :
29 : class UpdaterFor64Plus1 {
30 : public:
31 22 : UpdaterFor64Plus1() = default;
32 34 : ~UpdaterFor64Plus1() = default;
33 : UpdaterFor64Plus1(const UpdaterFor64Plus1&) = delete;
34 : UpdaterFor64Plus1& operator=(const UpdaterFor64Plus1&) = delete;
35 :
36 : void SaveReplaceInfo(const NewRankInfo& rank);
37 : void UpdateRankGraph(RankGraph* rankGraph, const RankTableInfo* rankTable) const;
38 :
39 : private:
40 : void UpdateNetInstance(
41 : NetInstance* fabricGroup, LocalId localId, LocalId replacedLocalId, const RankTableInfo* rankTable) const;
42 : std::string GetPortFromSet(std::set<string>& ports, u32 linkIdx) const;
43 : std::shared_ptr<PhyTopo::Link> GetPeer2PlaneEdges(
44 : u32 backupPlaneId, shared_ptr<NetInstance::Peer> peer,
45 : std::shared_ptr<Graph<PhyTopo::Node, PhyTopo::Link>> phyTopoGraph, u32 expectedPortNum,
46 : const std::set<LinkProtocol>& expectedProtocols = {}) const;
47 : void AddPeer2BackupLinks(
48 : std::shared_ptr<NetInstance::Peer> peer, std::shared_ptr<NetInstance::Peer> backupPeer, LocalId replacedLocalId,
49 : NetInstance* netInstance, const RankTableInfo* rankTable) const;
50 : bool IsSameX(LocalId srcLocalId, LocalId dstLocalId) const;
51 : bool IsSameY(LocalId srcLocalId, LocalId dstLocalId) const;
52 : std::pair<u32, u32> GetLinkIndex(LocalId localId, LocalId replacedLocalId) const; // <BackupPlaneId, addr idx>
53 :
54 : std::unordered_map<std::string, std::pair<LocalId, LocalId>> replaceInfo{}; // <R0Id, <localId, replacedLocalId>>
55 : };
56 :
57 : } // namespace Hccl
58 :
59 : #endif // UPDATER_FOR_64_PLUS_1_H
|