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_EXECUTOR_H
12 : #define COLL_REDUCESCATTER_RING_ZEROCOPY_EXECUTOR_H
13 : #include "coll_reduce_scatter_executor.h"
14 :
15 : namespace hccl {
16 : class CollReduceScatterRingZerocopyExecutor : public CollReduceScatterExecutor {
17 : public:
18 : explicit CollReduceScatterRingZerocopyExecutor(const HcclDispatcher dispatcher,
19 : std::unique_ptr<TopoMatcher> &topoMatcher);
20 0 : ~CollReduceScatterRingZerocopyExecutor() override = default;
21 :
22 : protected:
23 : HcclResult CalcCommInfo(std::vector<LevelNSubCommTransport>& opTransport) override;
24 : u32 level0Rank_ = INVALID_VALUE_RANKID;
25 : u32 level1Rank_ = INVALID_VALUE_RANKID;
26 : u32 level2Rank_ = INVALID_VALUE_RANKID;
27 : u32 level0RankSize_ = INVALID_VALUE_RANKSIZE;
28 : u32 level1RankSize_ = INVALID_VALUE_RANKSIZE;
29 : u32 level2RankSize_ = INVALID_VALUE_RANKSIZE;
30 :
31 : private:
32 : void ParseParam(const OpParam& param) override;
33 : /* *************** 资源计算 *************** */
34 : std::set<u32> commTargetUserRankSet_;
35 : HcclResult CalcStreamNum(u32& streamNum) override;
36 : HcclResult CalcLevel0CommInfo(TransportMemType inputType,
37 : TransportMemType outputType, std::vector<LevelNSubCommTransport>& opTransport) override;
38 : HcclResult CalcTransportMemType(TransportMemType &inputType, TransportMemType &outputType);
39 : u64 CalcLoopMaxCount(const u32 unitSize) override;
40 :
41 : /* *************** 算法编排 *************** */
42 : HcclResult SemiRingReduceScatter(
43 : const std::string &tag, DeviceMem inputMem, DeviceMem outputMem,
44 : const u64 count, const HcclDataType dataType, const HcclReduceOp reductionOp,
45 : const std::vector<std::vector<Slice> > multRingsSliceZero, Stream stream, s32 profStage,
46 : const u64 baseOffset, const HcomCollOpInfo *opInfo,
47 : const std::vector<std::vector<Slice>> multRingsUserMemSlice);
48 : HcclResult RunIntraSeverReduceScatter(const std::string &tag, DeviceMem &inputMem, DeviceMem &outputMem,
49 : const u64 count, const HcclDataType &dataType, const HcclReduceOp &reductionOp,
50 : const std::vector<std::vector<Slice>> &multRingsSliceZero, const Stream &stream, s32 profStage,
51 : const u64 baseOffset = 0, const HcomCollOpInfo *opInfo = nullptr,
52 : const std::vector<std::vector<Slice>> &multRingsUserMemSlice = std::vector<std::vector<Slice>>(0),
53 : const bool disableDMAReduce = false);
54 : HcclResult KernelRunIntraServerPre(const OpParam ¶m, ExecMem &execMem) override;
55 : HcclResult KernelRunInterServer(const OpParam ¶m, ExecMem &execMem) override;
56 : virtual HcclResult KernelRunInterServerPostProcess(const OpParam ¶m, const ExecMem &execMem);
57 :
58 : virtual HcclResult CalcLevel0DataSlices(const OpParam ¶m, const ExecMem &execMem, std::vector<Slice> &dataSegsSlice);
59 : virtual HcclResult KernelRunInterServerPreProcess(const OpParam ¶m, const ExecMem &execMem);
60 : };
61 :
62 : } // namespace hccl
63 :
64 : #endif
|