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