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_2D
12 : #define HCCLV2_INS_TEMP_ALL_GATHER_MESH_2D
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 InsTempAllGatherMesh2D : public InsAlgTemplateBase {
21 : public:
22 : explicit InsTempAllGatherMesh2D(
23 : const RankId virtualRank, const u32 tempRankSize, const std::vector<std::vector<RankId>>& tempVTopo,
24 : const std::map<RankId, u32>& tempVirtRankMap);
25 : ~InsTempAllGatherMesh2D() override;
26 :
27 0 : std::string Describe() const override
28 : {
29 0 : return StringFormat("Instruction based Template of all gather mesh 2d with tempRankSize [%u].", tempRankSize_);
30 : }
31 0 : u32 CalcScratchMultiple(const BufferType& inBufferTpye, const BufferType& outBufferTpye)
32 : {
33 : (void)inBufferTpye;
34 : (void)outBufferTpye;
35 0 : if (op_.opMode == OpMode::OPBASE) {
36 0 : HCCL_INFO("[InsTempAllGatherMesh2D][CalcScratchMultiple] templateScratchMultiplier[%llu]", tempRankSize_);
37 0 : return tempRankSize_;
38 : } else {
39 0 : HCCL_INFO("[InsTempAllGatherMesh2D][CalcScratchMultiple] templateScratchMultiplier[0](offload)");
40 0 : return 0;
41 : }
42 : }
43 :
44 : HcclResult GenExtIns(
45 : const TempFuncs& tempFuncs, const TemplateDataParams& tempAlgParams, const ResLinks& tempLinks,
46 : std::vector<InsQuePtr>& tempInsQues);
47 : HcclResult Run2DStep1(std::vector<InsQuePtr>& xInsQues, std::vector<InsQuePtr>& yInsQues);
48 : HcclResult Run2DStep2(std::vector<InsQuePtr>& xInsQues, std::vector<InsQuePtr>& yInsQues);
49 :
50 : HcclResult CalcRes(AlgTempResReq& tempResReq) override;
51 :
52 : private:
53 : HcclResult LocalDataCopy(std::vector<InsQuePtr>& tempInsQues);
54 : HcclResult PostLocalCopy(std::vector<InsQuePtr>& tempInsQues);
55 :
56 : HcclResult RunMesh(
57 : const u32 myAlgRank, RankId globalSrcRank, int rankOffset, const std::vector<RankId>& vTopo,
58 : std::vector<InsQuePtr>& tempInsQues, u64 xyOffset, u64 size, DmaMode dmaMode);
59 :
60 : u32 majorQueNum_ = 0;
61 : u32 xQueNum_ = 0;
62 : u32 yQueNum_ = 0;
63 : TemplateDataParams tempAlgParams_;
64 : ResLinks tempLinks_;
65 : TempFuncs tempFuncs_;
66 : };
67 :
68 : } // namespace Hccl
69 :
70 : #endif // !HCCLV2_INS_TEMP_ALL_GATHER_MESH
|