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_ALLGATHER_PIPELINE_FOR_910_93_EXECUTOR_H
12 : #define COLL_ALLGATHER_PIPELINE_FOR_910_93_EXECUTOR_H
13 :
14 : #include "coll_all_gather_executor.h"
15 :
16 : namespace hccl {
17 : class CollAllGatherPipelineFor91093Executor : public CollAllGatherExecutor {
18 : public:
19 : explicit CollAllGatherPipelineFor91093Executor(
20 : const HcclDispatcher dispatcher, std::unique_ptr<TopoMatcher>& topoMatcher);
21 0 : ~CollAllGatherPipelineFor91093Executor() override = default;
22 :
23 : // 流水线编排
24 : HcclResult Orchestrate(OpParam& param, AlgResourceResponse& algRes) override;
25 :
26 : private:
27 : // 资源计算
28 : HcclResult CalcStreamNum(u32& streamNum) override;
29 : HcclResult CalcCommInfo(std::vector<LevelNSubCommTransport>& opTransport) override;
30 : HcclResult CalcLevel0CommInfo(
31 : TransportMemType inputType, TransportMemType outputType,
32 : std::vector<LevelNSubCommTransport>& opTransport) override;
33 : HcclResult CalcLevel2CommInfo(
34 : TransportMemType inputType, TransportMemType outputType,
35 : std::vector<LevelNSubCommTransport>& opTransport) override;
36 : HcclResult CalcTransportMemType(TransportMemType& inputType, TransportMemType& outputType);
37 :
38 : // 算法编排
39 : u64 CalcLoopMaxCount(const u64 cclBuffSize, const u32 unitSize) override;
40 : HcclResult RunLoop(OpParam& param);
41 : HcclResult RunL2Stage(const OpParam& param, ExecMem& execMem, u64 loopIdx, u64 memIdx, u64 bufferSliceNum);
42 : HcclResult RunL1L0Stage(const OpParam& param, ExecMem& lastExecMem, u64 loopIdx, u64 memIdx, u64 bufferSliceNum);
43 :
44 : // 层级算法调用方法(从模板移动到执行器)
45 : HcclResult KernelRunInterSuperPod(const OpParam& param, ExecMem& execMem, u64 baseOffset); // 跨超
46 : HcclResult KernelRunIntraServer(const OpParam& param, ExecMem& execMem, u64 baseOffset); // server内
47 : HcclResult KernelRunInterServer(const OpParam& param, ExecMem& execMem, u64 baseOffset); // 跨server
48 :
49 : virtual std::vector<Slice> PrepareSlicesL2(
50 : const OpParam& param, const SubCommInfo& level2CommInfo, const SubCommInfo& level1CommInfo,
51 : const SubCommInfo& level0CommInfo, u32 perDataSize, u64 inputMemSize) const;
52 : virtual std::vector<Slice> PrepareSlicesL1(
53 : const OpParam& param, const SubCommInfo& level2CommInfo, const SubCommInfo& level1CommInfo,
54 : const SubCommInfo& level0CommInfo, u32 perDataSize, u64 inputMemSize) const;
55 : virtual HcclResult PrepareSlicesL0(
56 : std::vector<std::vector<Slice>>& multRingsSlice, const OpParam& param, const SubCommInfo& level2CommInfo,
57 : const SubCommInfo& level1CommInfo, const SubCommInfo& level0CommInfo, u32 perDataSize, u64 inputMemSize);
58 : virtual HcclResult PrepareUserMemSlices(
59 : std::vector<std::vector<Slice>>& userMemSlices, const std::vector<std::vector<Slice>>& multRingsSlice,
60 : const OpParam& param, const SubCommInfo& level2CommInfo, const SubCommInfo& level1CommInfo,
61 : const SubCommInfo& level0CommInfo, u32 perDataSize, u64 inputMemSize);
62 :
63 : HcclResult DoubleRingAllGather(
64 : const std::string& tag, DeviceMem inputMem, DeviceMem outputMem, const u64 count, const HcclDataType dataType,
65 : const std::vector<std::vector<Slice>> multRingsSliceZero, Stream stream, s32 profStage, const u64 baseOffset,
66 : const HcomCollOpInfo* opInfo, const std::vector<std::vector<Slice>> multRingsUserMemSlice);
67 :
68 : HcclResult GetSubStreamInfoOnOneRing(
69 : const u32 ringIndex, std::vector<Stream>& subStreamsInOneRing,
70 : std::vector<std::shared_ptr<LocalNotify>>& mainSignalsInOneRing,
71 : std::vector<std::shared_ptr<LocalNotify>>& subSignalsInOneRing) override;
72 : // 成员变量
73 : u32 unitSize_ = 0;
74 :
75 : Stream mainStreamL2_; // Reserved slave stream for L2.
76 : std::vector<Stream> subStreams_;
77 : Stream mainStreamL1L0_; // Main stream for L1/L0.
78 : std::vector<Stream> ringSubStreams_;
79 : std::shared_ptr<LocalNotify> notifyL2ToL1L0A_{nullptr};
80 : std::shared_ptr<LocalNotify> notifyL1L0ToL2A_{nullptr};
81 : std::shared_ptr<LocalNotify> notifyL2ToL1L0B_{nullptr};
82 : std::shared_ptr<LocalNotify> notifyL1L0ToL2B_{nullptr};
83 : std::vector<std::shared_ptr<LocalNotify>> notifyRingMain_;
84 : std::vector<std::shared_ptr<LocalNotify>> notifyRingSub_;
85 : SubCommInfo level0CommInfo_{}; // L0层通信域信息
86 : SubCommInfo level1CommInfo_{}; // L1层通信域信息
87 : SubCommInfo level2CommInfo_{}; // L2层通信域信息
88 :
89 : DeviceMem cclInputAMem_;
90 : DeviceMem cclOutputAMem_;
91 : DeviceMem cclInputBMem_;
92 : DeviceMem cclOutputBMem_;
93 : u64 cclInputSizeHalved_{0};
94 : u64 cclOutputSizeHalved_{0};
95 :
96 : HcomCollOpInfo l0OpInfo_{};
97 : };
98 :
99 : } // namespace hccl
100 :
101 : #endif
|