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(const RankId virtualRank, const u32 tempRankSize,
23 : 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(
37 : "[InsTempAllGatherMesh2D][CalcScratchMultiple] templateScratchMultiplier[%llu]", tempRankSize_);
38 0 : return tempRankSize_;
39 : } else {
40 0 : HCCL_INFO(
41 : "[InsTempAllGatherMesh2D][CalcScratchMultiple] templateScratchMultiplier[0](offload)");
42 0 : return 0;
43 : }
44 : }
45 :
46 : HcclResult GenExtIns(const TempFuncs &tempFuncs, const TemplateDataParams &tempAlgParams,
47 : const ResLinks &tempLinks,
48 : std::vector<InsQuePtr> &tempInsQues);
49 : HcclResult Run2DStep1(std::vector<InsQuePtr> &xInsQues, std::vector<InsQuePtr> &yInsQues);
50 : HcclResult Run2DStep2(std::vector<InsQuePtr> &xInsQues, std::vector<InsQuePtr> &yInsQues);
51 :
52 : HcclResult CalcRes(AlgTempResReq &tempResReq) override;
53 :
54 : private:
55 : HcclResult LocalDataCopy(std::vector<InsQuePtr> &tempInsQues);
56 : HcclResult PostLocalCopy(std::vector<InsQuePtr> &tempInsQues);
57 :
58 : HcclResult RunMesh(const u32 myAlgRank, RankId globalSrcRank, int rankOffset, const std::vector<RankId> &vTopo,
59 : std::vector<InsQuePtr> &tempInsQues, u64 xyOffset, u64 size, DmaMode dmaMode);
60 :
61 : u32 majorQueNum_ = 0;
62 : u32 xQueNum_ = 0;
63 : u32 yQueNum_ = 0;
64 : TemplateDataParams tempAlgParams_;
65 : ResLinks tempLinks_;
66 : TempFuncs tempFuncs_;
67 : };
68 :
69 : } // namespace Hccl
70 :
71 : #endif // !HCCLV2_INS_TEMP_ALL_GATHER_MESH
|