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(const HcclDispatcher dispatcher,
20 : 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(TransportMemType inputType,
37 : TransportMemType outputType, std::vector<LevelNSubCommTransport>& opTransport) override;
38 : HcclResult CalcExchangeCommInfo(std::vector<LevelNSubCommTransport>& opTransport);
39 : u64 CalcLoopMaxCount(const u32 unitSize) override;
40 :
41 : /* *************** 算法编排 *************** */
42 : HcclResult KernelRunIntraServerPre(const OpParam ¶m, ExecMem &execMem) override;
43 : HcclResult KernelRunInterServer(const OpParam ¶m, ExecMem &execMem) override;
44 :
45 : HcclResult RunIntraServer(const OpParam ¶m, const ExecMem &execMem, u32 step);
46 : HcclResult RunInterServerPreProcess(const OpParam ¶m, const ExecMem &execMem, u32 step);
47 : HcclResult RunInterServer(const OpParam ¶m, ExecMem &execMem, u32 step);
48 : HcclResult RunInterServerPostProcess(const OpParam ¶m, const ExecMem &execMem, u32 step);
49 : HcclResult ExchangeData(
50 : const OpParam ¶m, const ExecMem &execMem, u32 step, u32 remoteRankSend, u32 remoteRankRecv);
51 : HcclResult RunSuperPodPreSync(const OpParam ¶m);
52 : HcclResult RunSuperPod(const OpParam ¶m, const ExecMem &execMem, u32 step);
53 : HcclResult RunSuperPodPostSync(const OpParam ¶m);
54 : HcclResult RunSuperPodAndInterServerPostProcess(const OpParam ¶m, const ExecMem &execMem, u32 step);
55 : HcclResult RunFinallyProcess(const OpParam ¶m, const ExecMem &execMem);
56 :
57 : HcclResult CalExchangeRemoteRank(u32 &remoteRankSend, u32 &remoteRankRecv);
58 : HcclResult SemiRingReduceScatter(
59 : const std::string &tag, DeviceMem inputMem, DeviceMem outputMem,
60 : const u64 count, const HcclDataType dataType, const HcclReduceOp reductionOp,
61 : const std::vector<std::vector<Slice> > multRingsSliceZero, Stream stream, s32 profStage,
62 : 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
|