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_REDUCESCATTERV_DETER_EXECUTOR_H
12 : #define COLL_REDUCESCATTERV_DETER_EXECUTOR_H
13 : #include "coll_reduce_scatter_v_executor.h"
14 :
15 : // 对应 CollReduceScatterMeshDmaEliminationExecutor
16 : namespace hccl {
17 : class CollReduceScatterVDeterExecutor : public CollReduceScatterVExecutor {
18 : public:
19 : explicit CollReduceScatterVDeterExecutor(
20 : const HcclDispatcher dispatcher, std::unique_ptr<TopoMatcher>& topoMatcher);
21 0 : ~CollReduceScatterVDeterExecutor() override = default;
22 :
23 : private:
24 : void ParseParam(const OpParam& param) override;
25 : /* *************** 资源计算 *************** */
26 : HcclResult CalcCommInfo(std::vector<LevelNSubCommTransport>& opTransport) override;
27 : HcclResult CalcLevel0CommInfo(
28 : TransportMemType inputType, TransportMemType outputType,
29 : std::vector<LevelNSubCommTransport>& opTransport) override;
30 : HcclResult CalcLevel1CommInfoForMeshTopo(
31 : TransportMemType inputType, TransportMemType outputType, std::vector<LevelNSubCommTransport>& opTransport);
32 : u32 CalReduceStreamNum(const u32& localRankSize);
33 : HcclResult CalcStreamNum(u32& streamNum) override;
34 : HcclResult CalcScratchMemSize(u64& scratchMemSize) override;
35 : HcclResult CalcTransportMemType(TransportMemType& inputType, TransportMemType& outputType);
36 : u64 CalcLoopMaxCount(const u32 unitSize) override;
37 : HcclResult CalcCurCountsAndCurDispls(
38 : const u64 maxTotalCount, std::vector<u64>& countsLeft, std::vector<u64>& displs, std::vector<u64>& curCounts,
39 : std::vector<u64>& curDispls, bool& finished) override;
40 : bool IsHugeData(const u64 curSize, const OpParam& param) override;
41 : bool IsContainZeroSlice(const OpParam& param);
42 : /* *************** 算法编排 *************** */
43 : HcclResult KernelRun(const OpParam& param, ExecMem& execMem) override;
44 : HcclResult RunReduceScattervLevel0(const OpParam& param, ExecMem& execMem, SubCommInfo& level0CommInfo);
45 : HcclResult RunReduceScattervLevel1ForMeshTopo(const OpParam& param, ExecMem& execMem, SubCommInfo& level0CommInfo);
46 : HcclResult CalReduceScatterVSliceData(
47 : const OpParam& param, u32 level0RankSize, u32 level1RankSize, std::vector<Slice>& dataSlices);
48 : HcclResult RunReduceScattervLevel1(const OpParam& param, ExecMem& execMem, const SubCommInfo& level0CommInfo);
49 : u32 all2allOffset_ = 0;
50 : u64 maxCount_ = 0;
51 : bool isNeedSpaceBorrow_ = false;
52 : u64 minBiasOffset_ = 0;
53 : bool isMeshTopo_ = true;
54 : };
55 :
56 : } // namespace hccl
57 :
58 : #endif
|