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