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_REDUCESCATTER_RING_ZEROCOPY_EXCHANGE_PIPELINE_EXECUTOR_H
12 : #define COLL_REDUCESCATTER_RING_ZEROCOPY_EXCHANGE_PIPELINE_EXECUTOR_H
13 :
14 : #include "coll_reduce_scatter_executor.h"
15 :
16 : namespace hccl {
17 : class CollReduceScatterRingZerocopyExchangePipelineExecutor : public CollReduceScatterExecutor {
18 : public:
19 : explicit CollReduceScatterRingZerocopyExchangePipelineExecutor(
20 : const HcclDispatcher dispatcher, std::unique_ptr<TopoMatcher>& topoMatcher);
21 0 : ~CollReduceScatterRingZerocopyExchangePipelineExecutor() override = default;
22 :
23 : protected:
24 : HcclResult CalcCommInfo(std::vector<LevelNSubCommTransport>& opTransport) override;
25 : u32 level0Rank_ = INVALID_VALUE_RANKID;
26 : u32 level1Rank_ = INVALID_VALUE_RANKID;
27 : u32 level2Rank_ = INVALID_VALUE_RANKID;
28 : u32 level0RankSize_ = INVALID_VALUE_RANKSIZE;
29 : u32 level1RankSize_ = INVALID_VALUE_RANKSIZE;
30 : u32 level2RankSize_ = INVALID_VALUE_RANKSIZE;
31 :
32 : private:
33 : void ParseParam(const OpParam& param) override;
34 : /* *************** 资源计算 *************** */
35 : HcclResult CalcStreamNum(u32& streamNum) override;
36 : HcclResult CalcLevel0CommInfo(
37 : TransportMemType inputType, TransportMemType outputType,
38 : std::vector<LevelNSubCommTransport>& opTransport) override;
39 : HcclResult CalcExchangeCommInfo(std::vector<LevelNSubCommTransport>& opTransport);
40 : u64 CalcLoopMaxCount(const u32 unitSize) override;
41 :
42 : /* *************** 算法编排 *************** */
43 : HcclResult KernelRunIntraServerPre(const OpParam& param, ExecMem& execMem) override;
44 : HcclResult KernelRunInterServer(const OpParam& param, ExecMem& execMem) override;
45 :
46 : HcclResult RunIntraServer(const OpParam& param, const ExecMem& execMem, u32 step);
47 : HcclResult RunInterServerPreProcess(const OpParam& param, const ExecMem& execMem, u32 step);
48 : HcclResult RunInterServer(const OpParam& param, ExecMem& execMem, u32 step);
49 : HcclResult RunInterServerPostProcess(const OpParam& param, const ExecMem& execMem, u32 step);
50 : HcclResult
51 : ExchangeData(const OpParam& param, const ExecMem& execMem, u32 step, u32 remoteRankSend, u32 remoteRankRecv);
52 : HcclResult RunSuperPodPreSync(const OpParam& param);
53 : HcclResult RunSuperPod(const OpParam& param, const ExecMem& execMem, u32 step);
54 : HcclResult RunSuperPodPostSync(const OpParam& param);
55 : HcclResult RunSuperPodAndInterServerPostProcess(const OpParam& param, const ExecMem& execMem, u32 step);
56 : HcclResult RunFinallyProcess(const OpParam& param, const ExecMem& execMem);
57 :
58 : HcclResult CalExchangeRemoteRank(u32& remoteRankSend, u32& remoteRankRecv);
59 : HcclResult SemiRingReduceScatter(
60 : const std::string& tag, DeviceMem inputMem, DeviceMem outputMem, const u64 count, const HcclDataType dataType,
61 : const HcclReduceOp reductionOp, const std::vector<std::vector<Slice>> multRingsSliceZero, Stream stream,
62 : s32 profStage, const u64 baseOffset, const HcomCollOpInfo* opInfo,
63 : const std::vector<std::vector<Slice>> multRingsUserMemSlice);
64 :
65 : bool intraServerDone_{false};
66 : u64 curSize_{0};
67 : u32 unitSize_{0};
68 : u32 exchangeRemoteRankSend_{0};
69 : u32 exchangeRemoteRankRecv_{0};
70 : };
71 :
72 : } // namespace hccl
73 :
74 : #endif
|