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_SCATTER_EXECUTOR_H
12 : #define COLL_SCATTER_EXECUTOR_H
13 :
14 : #include "coll_comm_executor.h"
15 : #include "coll_alg_exec_registry.h"
16 :
17 : namespace hccl {
18 :
19 : class CollScatterExecutor : public CollCommExecutor {
20 : public:
21 : explicit CollScatterExecutor(const HcclDispatcher dispatcher, std::unique_ptr<TopoMatcher>& topoMatcher);
22 4 : ~CollScatterExecutor() override = default;
23 :
24 : HcclResult Orchestrate(OpParam& param, AlgResourceResponse& algRes) override;
25 :
26 : protected:
27 : /* *************** 资源计算 *************** */
28 : HcclResult CalcCommInfo(std::vector<LevelNSubCommTransport>& opTransport) override;
29 : virtual HcclResult CalcTransportMemType(TransportMemType& inputType, TransportMemType& outputType);
30 :
31 : /* *************** 算法编排 *************** */
32 : // 按Level0、Level1、Level2可继续进行拆分。
33 : virtual HcclResult KernelRunLevel1(
34 : DeviceMem& inputMem, u64 count, HcclDataType dataType, u32& commIndex, u32 root, u32& subRoot,
35 : CommPlane commLevel, Stream& stream);
36 : // 用于需要Loop的Executor
37 : virtual HcclResult RunLoop(OpParam& param, AlgResourceResponse& algRes);
38 : virtual HcclResult RunLoopInner(OpParam& param, ExecMem& execMem, AlgResourceResponse& algRes);
39 :
40 : virtual bool IsHugeData(u64 curSize);
41 : /* *************** 通用工具 *************** */
42 : virtual HcclResult PrepareDataSlice(u64 dataCount, u32 unitSize, u32 sliceNum, std::vector<Slice>& dataSlice);
43 : virtual HcclResult ReorderSlice(std::vector<Slice>& dataSlice, std::vector<u32>& order);
44 :
45 : bool DMAReduceFlag_{false}; // 是否DMA消减的标志
46 : private:
47 : };
48 :
49 : } // namespace hccl
50 :
51 : #endif
|