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_TEMP_ALL_GATHER_MESH
12 : #define HCCLV2_TEMP_ALL_GATHER_MESH
13 :
14 : #include "string_util.h"
15 :
16 : #include "alg_template_base_v2.h"
17 : #include "connected_link_mgr.h"
18 :
19 : namespace Hccl {
20 :
21 : class TempAllGatherMesh : public AlgTemplateBase {
22 : public:
23 : explicit TempAllGatherMesh(
24 : const RankId virtualRank, const u32 tempRankSize, const std::vector<std::vector<RankId>>& tempVTopo,
25 : const std::map<RankId, u32>& tempVirtRankMap);
26 : ~TempAllGatherMesh() override;
27 :
28 0 : std::string Describe() const override
29 : {
30 0 : return StringFormat("Template of all gather mesh with tempRankSize [%u].", tempRankSize_);
31 : }
32 :
33 : HcclResult GenPrimQue(
34 : const TempFuncs& tempFuncs, const RankSliceInfo& sliceInfoVec, const BuffInfo& buffInfo,
35 : const ResLinks& tempLinks, std::vector<PrimQuePtr>& tempPrimQues) override;
36 : using AlgTemplateBase::CalcSliceInfo;
37 : HcclResult CalcSliceInfo(const AllignInfo& allignInfo, const u64 dataSize, RankSliceInfo& sliceInfoVec) override;
38 :
39 : using AlgTemplateBase::CalcRes;
40 : HcclResult CalcRes(AlgTempResReq& tempResReq) override;
41 :
42 : using AlgTemplateBase::CalcResDetour;
43 : HcclResult CalcResDetour(const RankGraph* rankGraph, AlgTempResReq& tempResReq) override;
44 : HcclResult CalcResDetour(ConnectedLinkMgr* linkMgr, AlgTempResReq& tempResReq) override;
45 :
46 : private:
47 : HcclResult
48 : PreCopyOffload(const RankSliceInfo& sliceInfoVec, const bool forAllReduce, std::vector<PrimQuePtr>& tempPrimQues);
49 :
50 : HcclResult RunMesh(
51 : const u32 myAlgRank, const std::vector<RankId>& vTopo, const RankSliceInfo& sliceInfoVec,
52 : const ResLinks& tempLinks, std::vector<PrimQuePtr>& tempPrimQues);
53 :
54 : HcclResult RunIndividualPeerDetour(
55 : const RankId neighborRank, const SliceInfo& sendSlice, const SliceInfo& recvSlice, const ResLinks& tempLinks,
56 : std::vector<PrimQuePtr>& detourPrimQues);
57 : HcclResult RunIndividualPeer(
58 : const RankId neighborRank, const LinkData& neighborLinkData, const SliceInfo& sendSlice,
59 : const SliceInfo& recvSlice, PrimQuePtr currQue);
60 : HcclResult GetSendRecvLinks(
61 : const RankId neighborRank, const ResLinks& tempLinks,
62 : std::vector<std::vector<LinkDataIterator>>& sendRecvLinks) const;
63 :
64 : std::unique_ptr<PrimGroup> RunSendRecv(
65 : const RankId neighborRank, const LinkData& sendLinkData, const LinkData& recvLinkData,
66 : const SliceInfo& currSendSlice, const SliceInfo& currRecvSlice) const;
67 :
68 : u32 majorQueNum_ = 0;
69 : u32 queNumPerNeighbor_ = 1;
70 : };
71 :
72 : } // namespace Hccl
73 :
74 : #endif // !HCCLV2_TEMP_ALL_GATHER_MESH
|