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 COLL_ALLGATHER_RING_ZEROCOPY_PIPELINE_EXECUTOR_H
12 : #define COLL_ALLGATHER_RING_ZEROCOPY_PIPELINE_EXECUTOR_H
13 :
14 : #include "coll_all_gather_executor.h"
15 :
16 : namespace hccl {
17 : class CollAllGatherRingZerocopyPipelineExecutor : public CollAllGatherExecutor {
18 : public:
19 : explicit CollAllGatherRingZerocopyPipelineExecutor(
20 : const HcclDispatcher dispatcher, std::unique_ptr<TopoMatcher>& topoMatcher);
21 0 : ~CollAllGatherRingZerocopyPipelineExecutor() override = default;
22 :
23 : HcclResult Orchestrate(OpParam& param, AlgResourceResponse& algRes) override;
24 :
25 : private:
26 : /* *************** 资源计算 *************** */
27 : HcclResult CalcStreamNum(u32& streamNum) override;
28 : HcclResult CalcCommInfo(std::vector<LevelNSubCommTransport>& opTransport) override;
29 : HcclResult CalcLevel0CommInfo(
30 : TransportMemType inputType, TransportMemType outputType,
31 : std::vector<LevelNSubCommTransport>& opTransport) override;
32 : HcclResult CalcLevel2CommInfo(
33 : TransportMemType inputType, TransportMemType outputType,
34 : std::vector<LevelNSubCommTransport>& opTransport) override;
35 : HcclResult CalcExchangeCommInfo(std::vector<LevelNSubCommTransport>& opTransport);
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 KernelRunWithLoop(const OpParam& param, ExecMem& execMem, bool isLastLoop);
42 :
43 : HcclResult KernelRunInterSuperPod(const OpParam& param, ExecMem& execMem);
44 :
45 : HcclResult KernelRunIntraServerPost(const OpParam& param, ExecMem& execMem) override;
46 : HcclResult SemiRingAllGather(
47 : const std::string& tag, DeviceMem& inputMem, DeviceMem& outputMem, const u64 count,
48 : const HcclDataType& dataType, const std::vector<std::vector<Slice>>& multRingsSliceZero, const Stream& stream,
49 : s32 profStage, const u64 baseOffset, const HcomCollOpInfo* opInfo,
50 : const std::vector<std::vector<Slice>>& multRingsUserMemSlice);
51 :
52 : HcclResult KernelRunInterServer(const OpParam& param, ExecMem& execMem) override;
53 : HcclResult KernelRunInterServerPreProcess(const OpParam& param, ExecMem& execMem);
54 : HcclResult KernelRunInterServerPostProcess(const OpParam& param, ExecMem& execMem);
55 :
56 : HcclResult NotifyRdmaStreamStart();
57 : HcclResult WaitRdmaStreamFinish();
58 :
59 : HcclResult CalExchangeRemoteRank(u32& remoteRankSend, u32& remoteRankRecv);
60 : HcclResult CalcDataSlices(u64 sliceSize, u32 rankSize, std::vector<Slice>& dataSegsSlice);
61 :
62 : u32 unitSize_ = 0;
63 : u64 totalSize_ = 0; // 输入总数据量
64 :
65 : u32 level0Rank_ = INVALID_VALUE_RANKID;
66 : u32 level1Rank_ = INVALID_VALUE_RANKID;
67 : u32 level2Rank_ = INVALID_VALUE_RANKID;
68 : u32 level0RankSize_ = INVALID_VALUE_RANKSIZE;
69 : u32 level1RankSize_ = INVALID_VALUE_RANKSIZE;
70 : u32 level2RankSize_ = INVALID_VALUE_RANKSIZE;
71 :
72 : Stream mainStream_; // SDMA+localcopy
73 : std::vector<Stream> subStreams_;
74 : Stream rdmaMainStream_;
75 : std::vector<Stream> sdmaSubStreams_;
76 : std::shared_ptr<LocalNotify> notifyMainToRdma_;
77 : std::shared_ptr<LocalNotify> notifyRdmaToMain_;
78 : std::vector<std::shared_ptr<LocalNotify>> notifySdmaMain_;
79 : std::vector<std::shared_ptr<LocalNotify>> notifySdmaSub_;
80 :
81 : u32 memIdx_ = 0; // 表示当前算法编排使用CCLIN的第几块(0/1),是RDMA通信的源和目的,也是数据交换的起始
82 : u32 blockIdx_ = 0; // 表示当前超节点内在处理来自于第几个超节点的数据
83 : u64 blockSize_ = 0; // 表示来自于一个超节点的数据的大小
84 : };
85 :
86 : } // namespace hccl
87 :
88 : #endif
|