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