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_ALLGATHER_EXECUTOR_H
12 : #define COLL_ALLGATHER_EXECUTOR_H
13 : #include "coll_comm_executor.h"
14 : namespace hccl {
15 : class CollAllGatherExecutor : public CollCommExecutor {
16 : public:
17 : explicit CollAllGatherExecutor(const HcclDispatcher dispatcher, std::unique_ptr<TopoMatcher>& topoMatcher);
18 15 : ~CollAllGatherExecutor() override = default;
19 :
20 : HcclResult Orchestrate(OpParam& param, AlgResourceResponse& algRes) override;
21 :
22 : protected:
23 : // AllGather Loop Executor公共接口
24 : virtual u64 CalcLoopMaxCount(const u64 cclBuffSize, const u32 unitSize);
25 : virtual bool IsHugeData(const u64 curSize);
26 : virtual bool IsSmallData(const u64 size);
27 : virtual u64 CalcTotalCount(const OpParam& param) const;
28 : HcclResult RunLoop(OpParam& param, AlgResourceResponse& algRes); // non-virtual
29 :
30 : // agv
31 : virtual std::vector<u64> GetCounts(const OpParam& param) const;
32 : virtual std::vector<u64> GetDispls(const OpParam& param) const;
33 : virtual u64 GetCurrentCount(const OpParam& param, const std::vector<u64>& curCounts) const;
34 : virtual u64 CalcCurrentTotalCount(const OpParam& param, const std::vector<u64>& curCounts) const;
35 : virtual HcclOpMetaInfoDef GetOpMetaInfo(u32 algTypeLevel1, bool hugeData, bool smallData, bool dataSplit) const;
36 : virtual void UpdateOpParam(OpParam& param, std::vector<u64>& curCounts, std::vector<u64>& curDispls) const;
37 : bool CalcCountsDispls(
38 : const u64 maxTotalCount, std::vector<u64>& countsLeft, std::vector<u64>& displs, std::vector<u64>& curCounts,
39 : std::vector<u64>& curDispls);
40 : void PrintCountsDispls(bool finished, const std::vector<u64>& curCounts, const std::vector<u64>& curDispls);
41 : HcclResult RunLoopV(OpParam& param, AlgResourceResponse& algRes); // non-virtual
42 :
43 : // 工具类
44 : HcclResult PrepareAllgatherSlice(u32 sliceNum, u64 inputMemSize, std::vector<Slice>& dataSegsSlice) const;
45 :
46 : HcclResult CalculateLevel1AllgatherSlice(
47 : u64 inputMemSize, u32 level0RankSize, u32 level1RankSize, std::vector<std::vector<Slice>> multRingsSliceZero,
48 : std::vector<std::vector<Slice>>& multRingsSlice) const;
49 :
50 : HcclResult CalculateLevel2AllgatherSlice(
51 : u64 inputMemSize, u32 level0RankSize, u32 level1RankSize, u32 level2RankSize,
52 : std::vector<std::vector<Slice>> multRingsSliceZero, std::vector<Slice>& level2DataSlice, u32 ringIndex) const;
53 :
54 : HcclResult AllGatherLevel2(
55 : const std::string& tag, DeviceMem& inputMem, DeviceMem& outputMem, u64 count, HcclDataType dataType,
56 : Stream& stream, HcomCollOpInfo* opInfo = nullptr);
57 :
58 : bool DMAReduceFlag_{false}; // 是否DMA消减的标志
59 : bool isAllGatherV_{false};
60 : };
61 :
62 : } // namespace hccl
63 :
64 : #endif
|