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