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_BROADCAST_MESH_2D_TWO_SHOT
12 : #define HCCLV2_INS_TEMP_BROADCAST_MESH_2D_TWO_SHOT
13 :
14 : #include "string_util.h"
15 :
16 : #include "ins_alg_template_base.h"
17 : #include "executor_utils.h"
18 :
19 : namespace Hccl {
20 :
21 :
22 : class InsTempBroadcastMesh2DTwoShot : public InsAlgTemplateBase {
23 : public:
24 : explicit InsTempBroadcastMesh2DTwoShot(const RankId virtualRank, const u32 tempRankSize,
25 : const std::vector<std::vector<RankId>> &tempVTopo,
26 : const std::map<RankId, u32> &tempVirtRankMap);
27 : ~InsTempBroadcastMesh2DTwoShot() override;
28 :
29 0 : std::string Describe() const override
30 : {
31 0 : return StringFormat("Template of broadcast mesh with tempRankSize [%u].", tempRankSize_);
32 : }
33 :
34 : HcclResult GenExtIns(const TempFuncs &tempFuncs, const TemplateDataParams &templateDataParams,
35 : const ResLinks &tempLinks, std::vector<InsQuePtr> &tempInsQues);
36 : HcclResult CalcRes(AlgTempResReq &tempResReq) override;
37 :
38 : u32 CalcScratchMultiple(BufferType inBuffType, BufferType outBuffType);
39 :
40 : private:
41 0 : std::pair<u32, u32> GetRankPos(u32 rank) const { return make_pair(rank / sizeX_, rank % sizeX_); }
42 : HcclResult RunScatter(const ResLinks &tempLinks, std::vector<InsQuePtr> &tempInsQues, u64 baseOffset, u64 dataSize, u32 root, bool isRootX);
43 : HcclResult RunAllgather(const ResLinks &tempLinks, std::vector<InsQuePtr> &tempInsQues, u64 baseOffset, u64 dataSize, bool isX, bool isDma);
44 : HcclResult PreCopy(const TemplateDataParams &templateDataParams, std::vector<InsQuePtr> &tempInsQues);
45 : HcclResult PostCopy(const TemplateDataParams &templateDataParams, std::vector<InsQuePtr> &tempInsQues);
46 : HcclResult Run1RootScatterXY(u64 dataSize, const ResLinks &tempLinks, std::vector<InsQuePtr> &tempInsQues);
47 : HcclResult RunNRootScatterYX(u64 dataSize, const ResLinks &tempLinks, std::vector<InsQuePtr> &tempInsQues);
48 : HcclResult RunAllgatherYX(u64 dataSize, const ResLinks &tempLinks, std::vector<InsQuePtr> &tempInsQues);
49 : HcclResult RunAllgatherXY(u64 dataSize, const ResLinks &tempLinks, std::vector<InsQuePtr> &tempInsQues);
50 : // 列数
51 : u32 sizeX_{0};
52 : // 行数
53 : u32 sizeY_{0};
54 : //当前rank行号
55 : u32 curX_{0};
56 : //当前rank列号
57 : u32 curY_;
58 : u64 dataTypeSize_{0};
59 : u64 inputOffset_{0};
60 : };
61 :
62 : } // namespace Hccl
63 :
64 : #endif // !HCCLV2_INS_TEMP_BROADCAST_MESH
|