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 HCCLV2_TOPO_MATCH_MESH_RING
12 : #define HCCLV2_TOPO_MATCH_MESH_RING
13 : #include <string>
14 : #include <vector>
15 : #include <map>
16 :
17 : #include "types.h"
18 : #include "dev_type.h"
19 : #include "topo_match_base.h"
20 : #include "rank_gph.h"
21 : #include "net_instance.h"
22 :
23 : namespace Hccl {
24 :
25 : class TopoMatchMeshRing : public TopoMatchBase {
26 : public:
27 : explicit TopoMatchMeshRing(const RankId vRank, const u32 rankSize, const RankGraph *rankGraph,
28 : const DevType devType);
29 : ~TopoMatchMeshRing() override;
30 :
31 0 : std::string Describe() const override
32 : {
33 0 : return "Topo Match for combined Algorithm: level 0 Mesh, level 1 Ring.";
34 : }
35 : using TopoMatchBase::MatchTopo;
36 : HcclResult MatchTopo(std::vector<std::vector<std::vector<RankId>>> &vTopo,
37 : std::vector<std::vector<RankId>> &virtRanks,
38 : std::vector<std::map<RankId, u32>> &virtRankMap) override;
39 : private:
40 : HcclResult MeshRingTopoForAllLevel(std::set<RankId> rankSetR0,
41 : std::vector<std::vector<std::vector<RankId>>> &vTopo,
42 : std::vector<std::vector<RankId>> &virtRanks);
43 : std::vector<std::vector<RankId>> rankOnSameBoardVector_; // ranks vector with same boardIds in rack
44 : std::vector<std::vector<RankId>> rankOnSameSlotVector_; // ranks vector with same slotIds in rack
45 : std::vector<u32> numRanksPerBoard_; // ranks num with same boardIds in rack
46 : };
47 : } // namespace Hccl
48 :
49 : #endif // !HCCLV2_TOPO_MATCH_MESH_RING
|