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_TO_ALL_MESH_2D
12 : #define HCCLV2_INS_TEMP_ALL_TO_ALL_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 : constexpr u32 TEMPVTOPOSIZE = 2;
21 :
22 : class InsTempAlltoAllMesh2D : public InsAlgTemplateBase {
23 : public:
24 : explicit InsTempAlltoAllMesh2D(
25 : const RankId virtualRank, const u32 tempRankSize, const std::vector<std::vector<RankId>>& tempVTopo,
26 : const std::map<RankId, u32>& tempVirtRankMap);
27 : ~InsTempAlltoAllMesh2D() override;
28 :
29 0 : std::string Describe() const override
30 : {
31 0 : return StringFormat("Instruction based Template of all to all mesh 2d with tempRankSize [%u].", tempRankSize_);
32 : }
33 0 : u32 CalcScratchMultiple(const BufferType& inBufferTpye, const BufferType& outBufferTpye) const
34 : {
35 : (void)inBufferTpye;
36 : (void)outBufferTpye;
37 : // 单算子和图模式一致,AlltoAll的usrIn、scratchBuffer,usrOut大小一致
38 0 : return 1;
39 : }
40 :
41 : HcclResult GenExtIns(
42 : const TempFuncs& tempFuncs, const TemplateDataParams& tempAlgParams, const ResLinks& tempLinks,
43 : std::vector<InsQuePtr>& tempInsQues) const;
44 :
45 : HcclResult CalcRes(AlgTempResReq& tempResReq) override;
46 :
47 : private:
48 : HcclResult LocalDataCopy(const TemplateDataParams& tempAlgParams, std::vector<InsQuePtr>& tempInsQues);
49 : HcclResult PostLocalCopy(const TemplateDataParams& tempAlgParams, std::vector<InsQuePtr>& tempInsQues);
50 :
51 : HcclResult RunMeshX(
52 : std::vector<u64>& xDataInAddr, std::vector<u64>& xDataOutAddr, u64 xSize, BufferType srcBufferType,
53 : BufferType dstBufferType, DmaMode dmaMode, std::vector<InsQuePtr>& xInsQues, const ResLinks& tempLinks) const;
54 : HcclResult RunMeshY(
55 : std::vector<u64>& yDataInAddr, std::vector<u64>& yDataOutAddr, u64 ySize, BufferType srcBufferType,
56 : BufferType dstBufferType, DmaMode dmaMode, std::vector<InsQuePtr>& yInsQues, const ResLinks& tempLinks) const;
57 :
58 : u32 rankId_ = 0;
59 : u32 xRankId_ = 0;
60 : u32 yRankId_ = 0;
61 : u32 rankSize_ = 0;
62 : u32 xRankSize_ = 0;
63 : u32 yRankSize_ = 0;
64 : };
65 :
66 : } // namespace Hccl
67 :
68 : #endif // !HCCLV2_INS_TEMP_ALL_TO_ALL_MESH_2D
|