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_EXECUTOR_H
12 : #define COLL_REDUCESCATTERV_EXECUTOR_H
13 : #include "coll_comm_executor.h"
14 :
15 : namespace hccl {
16 :
17 : class CollReduceScatterVExecutor : public CollCommExecutor {
18 : public:
19 : explicit CollReduceScatterVExecutor(const HcclDispatcher dispatcher, std::unique_ptr<TopoMatcher>& topoMatcher);
20 0 : ~CollReduceScatterVExecutor() override = default;
21 :
22 : HcclResult Orchestrate(OpParam& param, AlgResourceResponse& algRes) override;
23 : HcclResult GetAdjInfo(AlgResourceResponse& algRes, AdjInfo& adjInfo) override;
24 :
25 : protected:
26 : // ReduceScatter Loop Executor公共接口
27 : virtual u64 CalcLoopMaxCount(const u32 unitSize);
28 : virtual HcclResult CalcCurCountsAndCurDispls(
29 : const u64 maxTotalCount, std::vector<u64>& countsLeft, std::vector<u64>& displs, std::vector<u64>& curCounts,
30 : std::vector<u64>& curDispls, bool& finished);
31 : virtual bool IsHugeData(const u64 curSize, const OpParam& param);
32 : virtual HcclResult RunLoop(OpParam& param, AlgResourceResponse& algRes);
33 :
34 : // 工具类
35 : void PrintCurCountAndCurDispls(const std::vector<u64>& curCounts, const std::vector<u64>& curDispls);
36 :
37 : bool CCLMemSlice_{true}; // 每次Loop是否需要对CCLMem进行切片
38 : bool DMAReduceFlag_{false}; // 是否DMA消减
39 : bool scratchMemFlag_{false}; // 是否需要申请scratch memory,不需要申请则传入outputmem为scratchmem
40 : u64 totalSize_{0}; // 总数据量
41 :
42 : private:
43 : HcclResult RunLoopInner(OpParam& param, const ReduceType& reduceType, ExecMem& execMem);
44 : };
45 :
46 : } // namespace hccl
47 :
48 : #endif
|