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 0 : }
32 : };
33 :
34 : class InsTempAllGatherNHR : public InsAlgTemplateBase {
35 : public:
36 : explicit InsTempAllGatherNHR(const RankId virtualRank, const u32 tempRankSize,
37 : const std::vector<std::vector<RankId>> &tempVTopo,
38 : const std::map<RankId, u32> &tempVirtRankMap);
39 : ~InsTempAllGatherNHR() override;
40 :
41 0 : std::string Describe() const override
42 : {
43 0 : return StringFormat("Template of all gather NHR with tempRankSize [%u].", tempRankSize_);
44 : }
45 :
46 : HcclResult CalcSliceInfo(const AllignInfo &allignInfo, const u64 dataSize, RankSliceInfo &sliceInfoVec) override;
47 : HcclResult CalcRes(AlgTempResReq &tempResReq) override;
48 : HcclResult GetStepInfo(u32 step, u32 nSteps, AicpuNHRStepInfo &stepInfo);
49 : RankId GetRankFromMap(const u32 rankIdx);
50 :
51 : HcclResult GenExtIns(const TempFuncs &tempFuncs, const TemplateDataParams &tempAlgParams,
52 : const ResLinks &tempLinks, std::vector<InsQuePtr> &tempInsQues);
53 :
54 0 : u32 CalcScratchMultiple(const BufferType &inBufferTpye, const BufferType &outBufferTpye) const
55 : {
56 : (void) inBufferTpye;
57 : (void) outBufferTpye;
58 0 : HCCL_INFO(
59 : "[InsTempAllGatherNHR][CalcScratchMultiple] templateScratchMultiplier[%llu]", tempRankSize_);
60 0 : return tempRankSize_;
61 : }
62 : private:
63 : TemplateDataParams tempAlgParams_;
64 : ResLinks tempLinks_;
65 :
66 : HcclResult LocalDataCopy(std::vector<InsQuePtr> &tempInsQues);
67 : HcclResult PostLocalCopy(std::vector<InsQuePtr> &tempInsQues);
68 : HcclResult RunNHR(std::vector<InsQuePtr> &tempInsQues);
69 : };
70 :
71 : } // namespace Hccl
72 :
73 : #endif // !HCCLV2_INS_TEMP_ALL_GATHER_NHR
|