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_SOLE_EXECUTOR
12 : #define HCCLV2_INS_BROADCAST_SOLE_EXECUTOR
13 :
14 : #include "ins_coll_alg_base.h"
15 :
16 : namespace Hccl {
17 :
18 : template <typename AlgTopoMatch, typename InsAlgTemplate>
19 : class InsV2BroadcastSoleExecutor : public InsCollAlgBase {
20 : public:
21 : explicit InsV2BroadcastSoleExecutor();
22 : ~InsV2BroadcastSoleExecutor() override;
23 :
24 0 : std::string Describe() const override { return "Instruction based broadcast 2D Executor."; }
25 :
26 : HcclResult Orchestrate(
27 : const RankGraph* rankGraph, const CollAlgOperator& op, const CollAlgParams& params, InsQuePtr insQue) override;
28 : HcclResult CalcResOffload(const RankGraph* rankGraph, const u64& dataSize, CollOffloadOpResReq& resReq) override;
29 : HcclResult CalcRes(const RankGraph* rankGraph, CollAlgResReq& algResReq) override;
30 :
31 : HcclResult Orchestrate(
32 : const AlgTopoInfo& topoInfo, const CollAlgOperator& op, const CollAlgParams& params, ConnectedLinkMgr* linkMgr,
33 : InsQuePtr insQue) override;
34 :
35 : private:
36 : HcclResult OrchestrateLoop(std::shared_ptr<InsAlgTemplate>& tempAlg);
37 : HcclResult CreateTemplates(std::shared_ptr<InsAlgTemplate>& algTemplatePtr);
38 : HcclResult InitCommInfo(const RankGraph* rankGraph);
39 : HcclResult InitCommInfo(const AlgTopoInfo& topoInfo);
40 : HcclResult GetTemplateResRequest(
41 : const RankGraph* rankGraph, std::shared_ptr<InsAlgTemplate>& algTemplate, AlgTempResReq& tempResReq) const;
42 : HcclResult GetTemplateResRequest(
43 : ConnectedLinkMgr* linkMgr, std::shared_ptr<InsAlgTemplate>& algTemplate, AlgTempResReq& tempResReq) const;
44 :
45 : std::vector<RankId> virtRanks_;
46 : std::map<RankId, u32> virtRankMap_; // map<virtRank, virtRankOrder>
47 : std::vector<std::vector<RankId>> vTopo_;
48 :
49 : std::vector<InsQuePtr> requiredQue_;
50 : ResLinks tempResLinks_;
51 : };
52 :
53 : } // namespace Hccl
54 :
55 : #endif // HCCLV2_INS_BROADCAST_SOLE_EXECUTOR
|