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