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_PARALLEL_EXECUTOR_H
12 : #define HCCLV2_INS_REDUCE_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 InsReduceParallelExecutor : public InsCollAlgBase {
19 : public:
20 : explicit InsReduceParallelExecutor();
21 : ~InsReduceParallelExecutor() override;
22 :
23 0 : std::string Describe() const override { return "Instruction based Reduce Parallel Executor."; }
24 :
25 : // HOST 接口
26 : HcclResult Orchestrate(
27 : const RankGraph* rankGraph, const CollAlgOperator& op, const CollAlgParams& params, InsQuePtr insQue) override;
28 : // AICPU 接口
29 : HcclResult Orchestrate(
30 : const AlgTopoInfo& topoInfo, const CollAlgOperator& op, const CollAlgParams& params, ConnectedLinkMgr* linkMgr,
31 : InsQuePtr insQue) override;
32 : HcclResult CalcResOffload(const RankGraph* rankGraph, const u64& dataSize, CollOffloadOpResReq& resReq) override;
33 : HcclResult CalcRes(const RankGraph* rankGraph, CollAlgResReq& algResReq) override;
34 :
35 : private:
36 : HcclResult GenInsQues(InsAlgTemplate0& tempAlgIntra, InsAlgTemplate1& tempAlgInter);
37 : void GenTemplateAlgParams0(
38 : const u64 dataOffset, const u64 dataCount, const u64 scratchOffset, TemplateDataParams& tempAlgParams) const;
39 : void GenTemplateAlgParams1(
40 : const u64 dataOffset, const u64 dataCount, const u64 scratchOffset, TemplateDataParams& tempAlgParams) const;
41 : void GetParallelDataSplitRate(std::vector<float>& splitDataSize) const;
42 : HcclResult
43 : PrepareResForTemplate(const RankGraph* rankGraph, InsAlgTemplate0& tempAlgIntra, InsAlgTemplate1& tempAlgInter);
44 : HcclResult
45 : PrepareResForTemplate(ConnectedLinkMgr* linkMgr, InsAlgTemplate0& tempAlgIntra, InsAlgTemplate1& tempAlgInter);
46 : HcclResult CalcLocalRoot();
47 :
48 : std::vector<std::vector<RankId>> virtRanks_;
49 : std::vector<std::map<RankId, u32>> virtRankMap_; // map<virtRank, virtRankOrder>
50 : std::vector<std::vector<std::vector<RankId>>> vTopo_;
51 :
52 : std::vector<InsQuePtr> reqQue_;
53 : std::vector<InsQuePtr> intraQue_;
54 : std::vector<InsQuePtr> interQue_;
55 : std::vector<InsQuePtr> syncQueues_;
56 : ResLinks intraLinks_;
57 : ResLinks interLinks_;
58 :
59 : u32 intraLocalRankSize_{0}; // server内算法rankSize
60 : u32 interLocalRankSize_{0}; // server间算法rankSize
61 :
62 : u32 intraLocalRoot_{0}; // server内算法root
63 : u32 interLocalRoot_{0}; // server间算法root
64 : };
65 :
66 : } // namespace Hccl
67 :
68 : #endif // HCCLV2_INS_REDUCE_PARALLEL_EXECUTOR_H
|