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_TEMP_ALL_GATHER_NHR
12 : #define HCCLV2_INS_TEMP_ALL_GATHER_NHR
13 :
14 : #include "string_util.h"
15 : #include "executor_utils.h"
16 : #include "ins_alg_template_base.h"
17 :
18 : namespace Hccl {
19 :
20 : using AicpuNHRStepInfo = struct AicpuNHRStepInfo {
21 : u32 step = 0;
22 : u32 myRank = 0;
23 : u32 nSlices;
24 : u32 toRank = 0;
25 : u32 fromRank = 0;
26 : std::vector<u32> txSliceIdxs;
27 : std::vector<u32> rxSliceIdxs;
28 :
29 0 : AicpuNHRStepInfo() : nSlices(0) {}
30 : };
31 :
32 : class InsTempAllGatherNHR : public InsAlgTemplateBase {
33 : public:
34 : explicit InsTempAllGatherNHR(
35 : const RankId virtualRank, const u32 tempRankSize, const std::vector<std::vector<RankId>>& tempVTopo,
36 : const std::map<RankId, u32>& tempVirtRankMap);
37 : ~InsTempAllGatherNHR() override;
38 :
39 0 : std::string Describe() const override
40 : {
41 0 : return StringFormat("Template of all gather NHR with tempRankSize [%u].", tempRankSize_);
42 : }
43 :
44 : HcclResult CalcSliceInfo(const AllignInfo& allignInfo, const u64 dataSize, RankSliceInfo& sliceInfoVec) override;
45 : HcclResult CalcRes(AlgTempResReq& tempResReq) override;
46 : HcclResult GetStepInfo(u32 step, u32 nSteps, AicpuNHRStepInfo& stepInfo);
47 : RankId GetRankFromMap(const u32 rankIdx);
48 :
49 : HcclResult GenExtIns(
50 : const TempFuncs& tempFuncs, const TemplateDataParams& tempAlgParams, const ResLinks& tempLinks,
51 : std::vector<InsQuePtr>& tempInsQues);
52 :
53 0 : u32 CalcScratchMultiple(const BufferType& inBufferTpye, const BufferType& outBufferTpye) const
54 : {
55 : (void)inBufferTpye;
56 : (void)outBufferTpye;
57 0 : HCCL_INFO("[InsTempAllGatherNHR][CalcScratchMultiple] templateScratchMultiplier[%llu]", tempRankSize_);
58 0 : return tempRankSize_;
59 : }
60 :
61 : private:
62 : TemplateDataParams tempAlgParams_;
63 : ResLinks tempLinks_;
64 :
65 : HcclResult LocalDataCopy(std::vector<InsQuePtr>& tempInsQues);
66 : HcclResult PostLocalCopy(std::vector<InsQuePtr>& tempInsQues);
67 : HcclResult RunNHR(std::vector<InsQuePtr>& tempInsQues);
68 : };
69 :
70 : } // namespace Hccl
71 :
72 : #endif // !HCCLV2_INS_TEMP_ALL_GATHER_NHR
|