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_INS_TEMP_ALL_GATHER_MESH
12 : #define HCCLV2_INS_TEMP_ALL_GATHER_MESH
13 :
14 : #include "string_util.h"
15 : #include "executor_utils.h"
16 : #include "ins_alg_template_base.h"
17 :
18 : namespace Hccl {
19 :
20 : class InsTempAllGatherMesh1D : public InsAlgTemplateBase {
21 : public:
22 : explicit InsTempAllGatherMesh1D(
23 : const RankId virtualRank, const u32 tempRankSize, const std::vector<std::vector<RankId>>& tempVTopo,
24 : const std::map<RankId, u32>& tempVirtRankMap);
25 : ~InsTempAllGatherMesh1D() override;
26 :
27 0 : std::string Describe() const override
28 : {
29 0 : return StringFormat("Instruction based Template of all gather mesh with tempRankSize [%u].", tempRankSize_);
30 : }
31 :
32 : HcclResult GenExtIns(
33 : const TempFuncs& tempFuncs, const TemplateDataParams& tempAlgParams, const ResLinks& tempLinks,
34 : std::vector<InsQuePtr>& tempInsQues);
35 : HcclResult CalcSliceInfo(const AllignInfo& allignInfo, const u64 dataSize, RankSliceInfo& sliceInfoVec) override;
36 : HcclResult CalcRes(AlgTempResReq& tempResReq) override;
37 0 : u32 CalcScratchMultiple(const BufferType& inBufferTpye, const BufferType& outBufferTpye) const
38 : {
39 : (void)inBufferTpye;
40 : (void)outBufferTpye;
41 0 : HCCL_INFO("[InsTempAllGatherMesh1D][CalcScratchMultiple] templateScratchMultiplier[%llu]", tempRankSize_);
42 0 : return tempRankSize_;
43 : }
44 :
45 : private:
46 : HcclResult LocalCopyToScratch(InsQuePtr tempInsQue);
47 : HcclResult LocalCopyToUsrOut(InsQuePtr tempInsQue);
48 : HcclResult RunMesh(const u32 myAlgRank, const std::vector<RankId>& vTopo, std::vector<InsQuePtr>& tempInsQues);
49 : HcclResult SingleRunMesh(const u32 myAlgRank, u32 connectedRank, std::vector<InsQuePtr>& tempInsQues, u32& queIdx);
50 : void PrepareLinkSlices(
51 : const u32 myAlgRank, const u32 connectedAlgRank, const std::vector<float>& dataSplitRate, const u32 linkIndex,
52 : std::vector<DataSlice>& txSrcSlices, std::vector<DataSlice>& txDstSlices, std::vector<DataSlice>& rxSrcSlices,
53 : std::vector<DataSlice>& rxDstSlices);
54 : u32 majorQueNum_ = 0;
55 : u32 queNumPerNeighbor_ = 1;
56 : bool enableInterRankCounterNotify_ = false;
57 : TemplateDataParams tempAlgParams_;
58 : ResLinks tempLinks_;
59 : };
60 :
61 : } // namespace Hccl
62 :
63 : #endif // !HCCLV2_INS_TEMP_ALL_GATHER_MESH
|