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