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(const RankId virtualRank, const u32 tempRankSize,
24 : 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(const TempFuncs &tempFuncs, const RankSliceInfo &sliceInfoVec, const BuffInfo &buffInfo,
34 : const ResLinks &tempLinks, std::vector<PrimQuePtr> &tempPrimQues) override;
35 : using AlgTemplateBase::CalcSliceInfo;
36 : HcclResult CalcSliceInfo(const AllignInfo &allignInfo, const u64 dataSize, RankSliceInfo &sliceInfoVec) override;
37 :
38 : using AlgTemplateBase::CalcRes;
39 : HcclResult CalcRes(AlgTempResReq &tempResReq) override;
40 :
41 : using AlgTemplateBase::CalcResDetour;
42 : HcclResult CalcResDetour(const RankGraph *rankGraph, AlgTempResReq &tempResReq) override;
43 : HcclResult CalcResDetour(ConnectedLinkMgr *linkMgr, AlgTempResReq &tempResReq) override;
44 :
45 : private:
46 : HcclResult PreCopyOffload(const RankSliceInfo &sliceInfoVec, const bool forAllReduce,
47 : std::vector<PrimQuePtr> &tempPrimQues);
48 :
49 : HcclResult RunMesh(const u32 myAlgRank, const std::vector<RankId> &vTopo, const RankSliceInfo &sliceInfoVec,
50 : const ResLinks &tempLinks, std::vector<PrimQuePtr> &tempPrimQues);
51 :
52 : HcclResult RunIndividualPeerDetour(const RankId neighborRank, const SliceInfo &sendSlice,
53 : const SliceInfo &recvSlice, const ResLinks &tempLinks,
54 : std::vector<PrimQuePtr> &detourPrimQues);
55 : HcclResult RunIndividualPeer(const RankId neighborRank, const LinkData &neighborLinkData,
56 : const SliceInfo &sendSlice, const SliceInfo &recvSlice, PrimQuePtr currQue);
57 : HcclResult GetSendRecvLinks(const RankId neighborRank, const ResLinks &tempLinks,
58 : std::vector<std::vector<LinkDataIterator>> &sendRecvLinks) const;
59 :
60 : std::unique_ptr<PrimGroup> RunSendRecv(const RankId neighborRank, const LinkData &sendLinkData,
61 : const LinkData &recvLinkData, const SliceInfo &currSendSlice,
62 : const SliceInfo &currRecvSlice) const;
63 :
64 : u32 majorQueNum_ = 0;
65 : u32 queNumPerNeighbor_ = 1;
66 : };
67 :
68 : } // namespace Hccl
69 :
70 : #endif // !HCCLV2_TEMP_ALL_GATHER_MESH
|