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_CONCURR_MESH
12 : #define HCCLV2_TEMP_ALL_GATHER_CONCURR_MESH
13 :
14 : #include "string_util.h"
15 :
16 : #include "alg_template_base_v2.h"
17 :
18 : namespace Hccl {
19 : class TempAllGatherConcurrMesh : public AlgTemplateBase {
20 : public:
21 : explicit TempAllGatherConcurrMesh(const RankId virtualRank, const u32 tempRankSize,
22 : const std::vector<std::vector<RankId>> &tempVTopo,
23 : const std::map<RankId, u32> &tempVirtRankMap);
24 : ~TempAllGatherConcurrMesh() override;
25 :
26 0 : std::string Describe() const override
27 : {
28 : return StringFormat("Template of all gather multi-dimensional concurrent mesh with tempRankSize [%u].",
29 0 : tempRankSize_);
30 : }
31 :
32 : HcclResult GenPrimQue(const TempFuncs &tempFuncs, const RankSliceInfo &sliceInfoVec, const BuffInfo &buffInfo,
33 : const ResLinks &tempLinks, std::vector<PrimQuePtr> &tempPrimQues) override;
34 :
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 : private:
42 : HcclResult PreCopyOffload(const RankSliceInfo &sliceInfoVec, const bool forAllReduce,
43 : std::vector<PrimQuePtr> &tempPrimQues);
44 :
45 : HcclResult RunOneDimMesh(const RankSliceInfo &sliceInfoVec, const ResLinks &tempLinks,
46 : std::vector<PrimQuePtr> &tempPrimQues);
47 : HcclResult RunMesh(const u32 myAlgRank, const std::vector<RankId> &vTopo, const RankSliceInfo &sliceInfoVec,
48 : const ResLinks &tempLinks, std::vector<PrimQuePtr> &tempPrimQues);
49 :
50 : HcclResult RunConcurrMesh(const RankSliceInfo &sliceInfoVec, const ResLinks &tempLinks,
51 : std::vector<PrimQuePtr> &tempPrimQues);
52 : HcclResult RunSingleDimension(const u32 &step, const u32 &dim, const RankSliceInfo &sliceInfoVec,
53 : const ResLinks &tempLinks, std::vector<PrimQuePtr> &dimPrimQues);
54 :
55 : std::unique_ptr<PrimSend> RunSend(const RankSliceInfo &sliceInfoVec, const std::vector<u32> &sendChunkIdxs,
56 : const u32 &sliceIdx, const RankId &neighborRank, const LinkData &priorLinkData);
57 : std::unique_ptr<PrimRecv> RunRecv(const RankSliceInfo &sliceInfoVec, const std::vector<u32> &recvChunkIdxs,
58 : const u32 &sliceIdx, const RankId &neighborRank, const LinkData &priorLinkData);
59 : };
60 :
61 : } // namespace Hccl
62 :
63 : #endif // !HCCLV2_TEMP_ALL_GATHER_CONCURR_MESH
|