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(
23 : const RankId virtualRank, const u32 tempRankSize, 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(
36 : const TempFuncs& tempFuncs, const TemplateDataParams& dataParams, const ResLinks& tempLinks,
37 : std::vector<InsQuePtr>& tempInsQues);
38 :
39 : private:
40 : HcclResult
41 : RunReduce(const TemplateDataParams& dataParams, const ResLinks& tempLinks, std::vector<InsQuePtr>& tempInsQues);
42 : HcclResult
43 : SendData(const TemplateDataParams& dataParams, const ResLinks& tempLinks, std::vector<InsQuePtr>& tempInsQues);
44 : HcclResult
45 : GatherData(const TemplateDataParams& dataParams, const ResLinks& tempLinks, std::vector<InsQuePtr>& tempInsQues);
46 : HcclResult ReduceData(const TemplateDataParams& dataParams, std::vector<InsQuePtr>& tempInsQues);
47 :
48 : u32 myIdx_ = INVALID_U32; // 本rank在通信域内的索引
49 : };
50 :
51 : } // namespace Hccl
52 :
53 : #endif // INS_TEMP_REDUCE_MESH1D
|