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 HCCLV2_INS_ALL_GATHER_PARALLEL_EXECUTOR_H
12 : #define HCCLV2_INS_ALL_GATHER_PARALLEL_EXECUTOR_H
13 : #include "ins_coll_alg_base.h"
14 :
15 : namespace Hccl {
16 :
17 :
18 : template <typename AlgTopoMatch, typename InsAlgTemplate0, typename InsAlgTemplate1>
19 : class InsAllGatherParallelExecutor : public InsCollAlgBase {
20 : public:
21 : explicit InsAllGatherParallelExecutor();
22 : ~InsAllGatherParallelExecutor() override;
23 :
24 0 : std::string Describe() const override
25 : {
26 0 : return "Instruction based All Gather Parallel Executor.";
27 : }
28 :
29 : // AICPU 接口
30 : HcclResult Orchestrate(const AlgTopoInfo &topoInfo, const CollAlgOperator &op, const CollAlgParams ¶ms,
31 : ConnectedLinkMgr *linkMgr, InsQuePtr insQue) override;
32 :
33 : // HOST 接口
34 : HcclResult Orchestrate(const RankGraph *rankGraph, const CollAlgOperator &op, const CollAlgParams ¶ms,
35 : InsQuePtr insQue) override;
36 :
37 : HcclResult CalcRes(const RankGraph *rankGraph, CollAlgResReq &algResReq) override;
38 :
39 : HcclResult CalcResOffload(const RankGraph *rankGraph, const u64 &dataSize,
40 : CollOffloadOpResReq &resReq) override;
41 :
42 : private:
43 : HcclResult GenInsQuesHost(InsAlgTemplate0 &tempAlgIntra, InsAlgTemplate1 &tempAlgInter);
44 : void GenTemplateAlgParamsInter0(const u64 dataOffset, const u64 dataCountPerLoopAixs0, const u64 scratchOffset, TemplateDataParams &tempAlgParamsInter0) const;
45 : void GenTemplateAlgParamsInter1(const u64 dataOffset, const u64 dataCountPerLoopAixs1, const u64 scratchOffset, TemplateDataParams &tempAlgParamsInter1) const;
46 : void GenTemplateAlgParamsIntra0(const u64 dataOffset, const u64 dataCountPerLoopAixs0, const u64 scratchOffset, TemplateDataParams &tempAlgParamsIntra0) const;
47 : void GenTemplateAlgParamsIntra1(const u64 dataOffset, const u64 dataCountPerLoopAixs1, const u64 scratchOffset, TemplateDataParams &tempAlgParamsIntra1) const;
48 : void GetParallelDataSplit(std::vector<float> &splitDataSize) const;
49 : HcclResult PrepareResForTemplate(ConnectedLinkMgr *linkMgr, InsAlgTemplate0 &tempAlgIntra, InsAlgTemplate1 &tempAlgInter);
50 : HcclResult PrepareResForTemplate(const RankGraph *rankGraph, InsAlgTemplate0 &tempAlgIntra, InsAlgTemplate1 &tempAlgInter);
51 :
52 : uint64_t rankIdxLevel0_{0};
53 : uint64_t rankIdxLevel1_{0};
54 : u32 rankSizeLevel0_{0};
55 : u32 rankSizeLevel1_{0};
56 :
57 : const RankGraph *rankGraph_ = nullptr;
58 :
59 : std::vector<std::vector<RankId>> virtRanks_;
60 : std::vector<std::map<RankId, u32>> virtRankMap_; // map<virtRank, virtRankOrder>
61 : std::vector<std::vector<std::vector<RankId>>> vTopo_;
62 :
63 : std::vector<InsQuePtr> requiredQue_;
64 : std::vector<InsQuePtr> intraQue_;
65 : std::vector<InsQuePtr> interQue_;
66 : std::vector<InsQuePtr> syncQueues_;
67 : ResLinks intraLinks_;
68 : ResLinks interLinks_;
69 :
70 : const RankGraph *rankGraphPtr_ = nullptr;
71 : };
72 :
73 : } // namespace Hccl
74 :
75 : #endif // HCCLV2_INS_ALL_GATHER_PARALLEL_EXECUTOR_H
|