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 { return "Instruction based Broadcast Parallel Executor."; }
25 :
26 : HcclResult CalcRes(const RankGraph* rankGraph, CollAlgResReq& algResReq) override;
27 :
28 : HcclResult CalcResOffload(const RankGraph* rankGraph, const u64& dataSize, CollOffloadOpResReq& resReq) override;
29 : // HOST 接口
30 : HcclResult Orchestrate(
31 : const RankGraph* rankGraph, const CollAlgOperator& op, const CollAlgParams& params, InsQuePtr insQue) override;
32 : // AICPU 接口
33 : HcclResult Orchestrate(
34 : const AlgTopoInfo& topoInfo, const CollAlgOperator& op, const CollAlgParams& params, ConnectedLinkMgr* linkMgr,
35 : InsQuePtr insQue) override;
36 :
37 : private:
38 : void GetParallelDataSplit(std::vector<float>& splitDataSize) const;
39 : HcclResult CalcLocalRoot();
40 : // Host
41 : HcclResult
42 : PrepareResForTemplate(const RankGraph* rankGraph, InsAlgTemplate0& tempAlgIntra, InsAlgTemplate1& tempAlgInter);
43 : // Aicpu
44 : HcclResult
45 : PrepareResForTemplate(ConnectedLinkMgr* linkMgr, InsAlgTemplate0& tempAlgIntra, InsAlgTemplate1& tempAlgInter);
46 : void GenDataParams(
47 : const u64 dataOffset, const u64 sliceCount, const u64 scratchOffsetCount, TemplateDataParams& dataParams) const;
48 : HcclResult GenInsQues(InsAlgTemplate0& tempAlgIntra, InsAlgTemplate1& tempAlgInter);
49 :
50 : u32 intraLocalRankSize_{0}; // server内算法rankSize
51 : u32 interLocalRankSize_{0}; // server间算法rankSize
52 :
53 : RankId intraLocalRank_{INVALID_RANKID}; // server内算法rank
54 : RankId interLocalRank_{INVALID_RANKID}; // server间算法rank
55 :
56 : u32 intraLocalRoot_{0}; // server内算法root
57 : u32 interLocalRoot_{0}; // server间算法root
58 :
59 : const RankGraph* rankGraph_ = nullptr;
60 : std::vector<InsQuePtr> requiredQue_;
61 : std::vector<InsQuePtr> intraQue_;
62 : std::vector<InsQuePtr> interQue_;
63 : std::vector<InsQuePtr> syncQueues_;
64 : ResLinks intraLinks_;
65 : ResLinks interLinks_;
66 :
67 : std::vector<std::vector<std::vector<RankId>>> vTopo_;
68 : std::vector<std::map<RankId, u32>> virtRankMap_; // map<virtRank, virtRankOrder>
69 : std::vector<std::vector<RankId>> virtRanks_;
70 :
71 : const RankGraph* rankGraphPtr_ = nullptr;
72 : };
73 :
74 : } // namespace Hccl
75 :
76 : #endif // HCCLV2_INS_BROADCAST_PARALLEL_EXECUTOR_H
|