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 :
17 : public:
18 : explicit CollAllGatherExecutor(const HcclDispatcher dispatcher, std::unique_ptr<TopoMatcher> &topoMatcher);
19 15 : ~CollAllGatherExecutor() override = default;
20 :
21 : HcclResult Orchestrate(OpParam& param, AlgResourceResponse& algRes) override;
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 ¶m) const;
28 : HcclResult RunLoop(OpParam ¶m, AlgResourceResponse &algRes); // non-virtual
29 :
30 : // agv
31 : virtual std::vector<u64> GetCounts(const OpParam ¶m) const;
32 : virtual std::vector<u64> GetDispls(const OpParam ¶m) const;
33 : virtual u64 GetCurrentCount(const OpParam ¶m, const std::vector<u64> &curCounts) const;
34 : virtual u64 CalcCurrentTotalCount(const OpParam ¶m, const std::vector<u64> &curCounts) const;
35 : virtual HcclOpMetaInfoDef GetOpMetaInfo(u32 algTypeLevel1, bool hugeData, bool smallData, bool dataSplit) const;
36 : virtual void UpdateOpParam(OpParam ¶m, std::vector<u64> &curCounts, std::vector<u64> &curDispls) const;
37 : bool CalcCountsDispls(const u64 maxTotalCount, std::vector<u64> &countsLeft,
38 : std::vector<u64> &displs, std::vector<u64> &curCounts, std::vector<u64> &curDispls);
39 : void PrintCountsDispls(bool finished, const std::vector<u64> &curCounts, const std::vector<u64> &curDispls);
40 : HcclResult RunLoopV(OpParam ¶m, AlgResourceResponse &algRes); // non-virtual
41 :
42 : // 工具类
43 : HcclResult PrepareAllgatherSlice(u32 sliceNum, u64 inputMemSize, std::vector<Slice> &dataSegsSlice) const;
44 :
45 : HcclResult CalculateLevel1AllgatherSlice(u64 inputMemSize, u32 level0RankSize, u32 level1RankSize,
46 : std::vector<std::vector<Slice>> multRingsSliceZero, std::vector<std::vector<Slice>> &multRingsSlice) const;
47 :
48 : HcclResult CalculateLevel2AllgatherSlice(u64 inputMemSize, u32 level0RankSize,
49 : u32 level1RankSize, u32 level2RankSize, std::vector<std::vector<Slice>> multRingsSliceZero,
50 : std::vector<Slice> &level2DataSlice, u32 ringIndex) const;
51 :
52 : HcclResult AllGatherLevel2(const std::string &tag, DeviceMem &inputMem, DeviceMem &outputMem,
53 : u64 count, HcclDataType dataType, Stream &stream, HcomCollOpInfo *opInfo = nullptr);
54 :
55 : bool DMAReduceFlag_{false}; // 是否DMA消减的标志
56 : bool isAllGatherV_{false};
57 : };
58 :
59 : } // namespace hccl
60 :
61 : #endif
|