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