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