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 INS_TEMP_REDUCE_MESH1D
12 : #define INS_TEMP_REDUCE_MESH1D
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 InsTempReduceMesh1D : public InsAlgTemplateBase {
21 : public:
22 : explicit InsTempReduceMesh1D(const RankId virtualRank, const u32 tempRankSize,
23 : const std::vector<std::vector<RankId>> &tempVTopo,
24 : const std::map<RankId, u32> &tempVirtRankMap);
25 : ~InsTempReduceMesh1D() override;
26 :
27 0 : std::string Describe() const override
28 : {
29 0 : return StringFormat("Template of reduce Mesh1D with tempRankSize [%u].", tempRankSize_);
30 : }
31 :
32 : HcclResult CalcRes(AlgTempResReq &tempResReq) override;
33 : u32 CalcScratchMultiple(BufferType inBuffType, BufferType outBuffType) const;
34 :
35 : HcclResult GenExtIns(const TempFuncs &tempFuncs, const TemplateDataParams &dataParams,
36 : const ResLinks &tempLinks, std::vector<InsQuePtr> &tempInsQues);
37 :
38 : private:
39 : HcclResult RunReduce(const TemplateDataParams &dataParams, const ResLinks &tempLinks,
40 : std::vector<InsQuePtr> &tempInsQues);
41 : HcclResult SendData(const TemplateDataParams &dataParams, const ResLinks &tempLinks,
42 : std::vector<InsQuePtr> &tempInsQues);
43 : HcclResult GatherData(const TemplateDataParams &dataParams, const ResLinks &tempLinks,
44 : std::vector<InsQuePtr> &tempInsQues);
45 : HcclResult ReduceData(const TemplateDataParams &dataParams, std::vector<InsQuePtr> &tempInsQues);
46 :
47 : u32 myIdx_ = INVALID_U32; // 本rank在通信域内的索引
48 : };
49 :
50 : } // namespace Hccl
51 :
52 : #endif // INS_TEMP_REDUCE_MESH1D
|