Line data Source code
1 : /**
2 : * Copyright (c) 2026 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 COLL_REDUCESCATTER_PIPELINE_FOR_910_93_EXECUTOR_H
12 : #define COLL_REDUCESCATTER_PIPELINE_FOR_910_93_EXECUTOR_H
13 : #include "coll_reduce_scatter_ring_for_910_93_executor.h"
14 :
15 : namespace hccl {
16 : class CollReduceScatterPipelineFor91093Executor
17 : : public CollReduceScatterRingFor91093Executor {
18 : public:
19 : explicit CollReduceScatterPipelineFor91093Executor(
20 : const HcclDispatcher dispatcher, std::unique_ptr<TopoMatcher> &topoMatcher);
21 0 : ~CollReduceScatterPipelineFor91093Executor() override = default;
22 :
23 : private:
24 : struct PipelineLoopContext {
25 : u64 countDataPerLoop;
26 : u64 countDataLastLoop;
27 : u64 sizeDataPerLoop;
28 : u64 numBlockTotal;
29 : u64 cclInputBufferSize;
30 : DeviceMem cclInputAMem;
31 : DeviceMem cclInputBMem;
32 : DeviceMem cclOutputAMem;
33 : DeviceMem cclOutputBMem;
34 : u8 *curInputPtr;
35 : u8 *curOutputPtr;
36 : };
37 :
38 : HcclResult CalcStreamNum(u32 &streamNum) override;
39 : u64 CalcLoopMaxCount(const u32 unitSize) override;
40 : HcclResult RunLoop(OpParam ¶m, AlgResourceResponse &algRes) override;
41 : HcclResult BuildPipelineLoopContext(OpParam ¶m, AlgResourceResponse &algRes,
42 : const u32 unitSize, PipelineLoopContext &ctx);
43 : HcclResult WaitForRemainingL2Signals(const OpParam ¶m, u64 numBlockTotal,
44 : Stream &streamL0L1, const std::shared_ptr<LocalNotify> ¬ifyL2toL0L1A,
45 : const std::shared_ptr<LocalNotify> ¬ifyL2toL0L1B);
46 : HcclResult RunIntraSeverReduceScatter(const std::string &tag, DeviceMem &inputMem, DeviceMem &outputMem,
47 : const u64 count, const HcclDataType &dataType, const HcclReduceOp &reductionOp,
48 : const std::vector<std::vector<Slice>> &multRingsSliceZero, const Stream &stream, s32 profStage,
49 : const u64 baseOffset = 0, const HcomCollOpInfo *opInfo = nullptr,
50 : const std::vector<std::vector<Slice>> &multRingsUserMemSlice = std::vector<std::vector<Slice>>(0),
51 : const bool disableDMAReduce = false) override;
52 :
53 : void SliceExecMem(const OpParam ¶m, ExecMem &execMem);
54 :
55 : HcclResult GetLevel2CommInfo(SubCommInfo &level2CommInfo);
56 :
57 : HcclResult RunL0L1Phase(OpParam ¶m, const PipelineLoopContext &ctx, u64 blockIdx, Stream &streamL0L1);
58 : HcclResult RunL2Phase(OpParam ¶m, const PipelineLoopContext &ctx, u64 blockIdx, Stream &streamL2);
59 :
60 : HcclResult KernelRunLevel0To1(const OpParam ¶m, ExecMem &execMem, Stream &streamL0L1, const u64 baseOffset);
61 : HcclResult KernelRunLevel2(const OpParam ¶m, ExecMem &execMem, Stream &streamL2, const u64 baseOffset);
62 :
63 : HcclResult PrepareDoubleRingSlices(u32 ringNum, const HcclDataType dataType,
64 : const HcomCollOpInfo *opInfo,
65 : const std::vector<std::vector<Slice>> &multRingsSliceZero,
66 : const std::vector<std::vector<Slice>> &multRingsUserMemSlice,
67 : std::vector<std::vector<Slice>> &userMemInputSlicesOfDoubleRing,
68 : std::vector<std::vector<u32>> &rankOrders);
69 :
70 : HcclResult RunLevel1Template(const OpParam ¶m, ExecMem &execMem,
71 : Stream &streamL0L1, u64 baseOffset, u32 commIndex, u32 sliceNum,
72 : u32 level1RankSize, u32 level2RankSize, u32 perDataSize);
73 :
74 : HcclResult RunLevel2Template(const OpParam ¶m, ExecMem &execMem,
75 : Stream &streamL2, u64 baseOffset, const SubCommInfo &level2CommInfo,
76 : u32 level2RankSize, u32 perDataSize);
77 :
78 : HcclResult DoubleRingReduceScatter(const std::string &tag, DeviceMem inputMem, DeviceMem outputMem,
79 : const u64 count, const HcclDataType dataType, const HcclReduceOp reductionOp,
80 : const std::vector<std::vector<Slice>> multRingsSliceZero, Stream stream, s32 profStage,
81 : const u64 baseOffset, const HcomCollOpInfo *opInfo,
82 : const std::vector<std::vector<Slice>> multRingsUserMemSlice, const bool disableDMAReduce);
83 :
84 : u32 GetLevel0RingNum() const override;
85 : };
86 :
87 : } // namespace hccl
88 :
89 : #endif
|