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(
19 : const HcclDispatcher dispatcher, 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(
37 : TransportMemType inputType, TransportMemType outputType,
38 : std::vector<LevelNSubCommTransport>& opTransport) override;
39 : HcclResult CalcTransportMemType(TransportMemType& inputType, TransportMemType& outputType);
40 : u64 CalcLoopMaxCount(const u32 unitSize) override;
41 :
42 : /* *************** 算法编排 *************** */
43 : HcclResult SemiRingReduceScatter(
44 : const std::string& tag, DeviceMem inputMem, DeviceMem outputMem, const u64 count, const HcclDataType dataType,
45 : const HcclReduceOp reductionOp, const std::vector<std::vector<Slice>> multRingsSliceZero, Stream stream,
46 : s32 profStage, const u64 baseOffset, const HcomCollOpInfo* opInfo,
47 : const std::vector<std::vector<Slice>> multRingsUserMemSlice);
48 : HcclResult RunIntraSeverReduceScatter(
49 : const std::string& tag, DeviceMem& inputMem, DeviceMem& outputMem, const u64 count,
50 : const HcclDataType& dataType, const HcclReduceOp& reductionOp,
51 : const std::vector<std::vector<Slice>>& multRingsSliceZero, const Stream& stream, s32 profStage,
52 : const u64 baseOffset = 0, const HcomCollOpInfo* opInfo = nullptr,
53 : const std::vector<std::vector<Slice>>& multRingsUserMemSlice = std::vector<std::vector<Slice>>(0),
54 : const bool disableDMAReduce = false);
55 : HcclResult KernelRunIntraServerPre(const OpParam& param, ExecMem& execMem) override;
56 : HcclResult KernelRunInterServer(const OpParam& param, ExecMem& execMem) override;
57 : virtual HcclResult KernelRunInterServerPostProcess(const OpParam& param, const ExecMem& execMem);
58 :
59 : virtual HcclResult
60 : CalcLevel0DataSlices(const OpParam& param, const ExecMem& execMem, std::vector<Slice>& dataSegsSlice);
61 : virtual HcclResult KernelRunInterServerPreProcess(const OpParam& param, const ExecMem& execMem);
62 : };
63 :
64 : } // namespace hccl
65 :
66 : #endif
|