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 INS_TEMP_GATHER_NHR
12 : #define INS_TEMP_GATHER_NHR
13 :
14 : #include "string_util.h"
15 :
16 : #include "ins_alg_template_base.h"
17 : #include "ins_temp_all_gather_nhr.h"
18 : namespace Hccl {
19 :
20 : class InsTempGatherNHR : public InsAlgTemplateBase {
21 : public:
22 : explicit InsTempGatherNHR(const RankId virtualRank, const u32 tempRankSize,
23 : const std::vector<std::vector<RankId>> &tempVTopo,
24 : const std::map<RankId, u32> &tempVirtRankMap);
25 : ~InsTempGatherNHR() override;
26 :
27 0 : std::string Describe() const override
28 : {
29 0 : return StringFormat("Template of Gather NHR with tempRankSize [%u].", tempRankSize_);
30 : }
31 :
32 : HcclResult Run(const TempFuncs &tempFuncs, const RankSliceInfo &sliceInfoVec, const BuffInfo &buffInfo,
33 : const ResLinks &tempLinks, std::vector<InsQuePtr> &tempInsQues) override;
34 : HcclResult CalcSliceInfo(const AllignInfo &allignInfo, const u64 dataSize, RankSliceInfo &sliceInfoVec) override;
35 : HcclResult CalcRes(AlgTempResReq &tempResReq) override;
36 : HcclResult GetScatterStepInfo(u32 step, u32 nSteps, AicpuNHRStepInfo &stepInfo) const;
37 : uint64_t GetExpandedMode() const;
38 : private:
39 : HcclResult PreCopy(const TempFuncs &tempFuncs, const RankSliceInfo &sliceInfoVec,
40 : std::vector<InsQuePtr> &tempInsQues);
41 : HcclResult PostCopy(const TempFuncs &tempFuncs, const RankSliceInfo &sliceInfoVec,
42 : std::vector<InsQuePtr> &tempInsQues);
43 :
44 : HcclResult BatchTxRx(AicpuNHRStepInfo &stepInfo, const ResLinks &tempLinks, InsQuePtr &queue, const RankSliceInfo &sliceInfoVec);
45 : HcclResult BatchSend(AicpuNHRStepInfo &stepInfo, const ResLinks &tempLinks, InsQuePtr &queue, const RankSliceInfo &sliceInfoVec, BufferType memType, u32 memOffset) const;
46 : HcclResult BatchRecv(AicpuNHRStepInfo &stepInfo, const ResLinks &tempLinks, InsQuePtr &queue, const RankSliceInfo &sliceInfoVec, BufferType memType, u32 memOffset) const;
47 : HcclResult BatchSR(AicpuNHRStepInfo &stepInfo, const ResLinks &tempLinks, InsQuePtr &queue, const RankSliceInfo &sliceInfoVec, BufferType memType, u32 memOffset) const;
48 :
49 : HcclResult GetGatherStepInfo(std::vector<AicpuNHRStepInfo> &nhrSteps) const;
50 :
51 : // 主要搬运所用的Buffer
52 : BufferType mainBufferType_;
53 : u64 mainBufferBaseOffset_{0};
54 : };
55 :
56 : } // namespace Hccl
57 :
58 : #endif /* INS_TEMP_GATHER_NHR */
|