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_BROADCAST_PARALLEL_EXECUTOR_H
12 : #define HCCLV2_INS_BROADCAST_PARALLEL_EXECUTOR_H
13 :
14 : #include "ins_coll_alg_base.h"
15 :
16 : namespace Hccl {
17 :
18 : template <typename AlgTopoMatch, typename InsAlgTemplate0, typename InsAlgTemplate1>
19 : class InsBroadcastParallelExecutor : public InsCollAlgBase {
20 : public:
21 : explicit InsBroadcastParallelExecutor();
22 : ~InsBroadcastParallelExecutor() override;
23 :
24 0 : std::string Describe() const override
25 : {
26 0 : return "Instruction based Broadcast Parallel Executor.";
27 : }
28 :
29 : HcclResult CalcRes(const RankGraph *rankGraph, CollAlgResReq &algResReq) override;
30 :
31 : HcclResult CalcResOffload(const RankGraph *rankGraph, const u64 &dataSize,
32 : CollOffloadOpResReq &resReq) override;
33 : // HOST 接口
34 : HcclResult Orchestrate(const RankGraph *rankGraph, const CollAlgOperator &op, const CollAlgParams ¶ms,
35 : InsQuePtr insQue) override;
36 : // AICPU 接口
37 : HcclResult Orchestrate(const AlgTopoInfo &topoInfo, const CollAlgOperator &op, const CollAlgParams ¶ms,
38 : ConnectedLinkMgr *linkMgr, InsQuePtr insQue) override;
39 :
40 : private:
41 : void GetParallelDataSplit(std::vector<float> &splitDataSize) const;
42 : HcclResult CalcLocalRoot();
43 : // Host
44 : HcclResult PrepareResForTemplate(const RankGraph *rankGraph, InsAlgTemplate0 &tempAlgIntra,
45 : InsAlgTemplate1 &tempAlgInter);
46 : // Aicpu
47 : HcclResult PrepareResForTemplate(ConnectedLinkMgr *linkMgr, InsAlgTemplate0 &tempAlgIntra,
48 : InsAlgTemplate1 &tempAlgInter);
49 : void GenDataParams(const u64 dataOffset, const u64 sliceCount, const u64 scratchOffsetCount,
50 : TemplateDataParams &dataParams) const;
51 : HcclResult GenInsQues(InsAlgTemplate0 &tempAlgIntra, InsAlgTemplate1 &tempAlgInter);
52 :
53 : u32 intraLocalRankSize_{0}; // server内算法rankSize
54 : u32 interLocalRankSize_{0}; // server间算法rankSize
55 :
56 : RankId intraLocalRank_{INVALID_RANKID}; // server内算法rank
57 : RankId interLocalRank_{INVALID_RANKID}; // server间算法rank
58 :
59 : u32 intraLocalRoot_{0}; // server内算法root
60 : u32 interLocalRoot_{0}; // server间算法root
61 :
62 : const RankGraph *rankGraph_ = nullptr;
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 : std::vector<std::vector<std::vector<RankId>>> vTopo_;
71 : std::vector<std::map<RankId, u32>> virtRankMap_; // map<virtRank, virtRankOrder>
72 : std::vector<std::vector<RankId>> virtRanks_;
73 :
74 : const RankGraph *rankGraphPtr_ = nullptr;
75 : };
76 :
77 : } // namespace Hccl
78 :
79 : #endif // HCCLV2_INS_BROADCAST_PARALLEL_EXECUTOR_H
|