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(
23 : const RankId virtualRank, const u32 tempRankSize, 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
33 : Run(const TempFuncs& tempFuncs, const RankSliceInfo& sliceInfoVec, const BuffInfo& buffInfo,
34 : const ResLinks& tempLinks, std::vector<InsQuePtr>& tempInsQues) override;
35 : HcclResult CalcSliceInfo(const AllignInfo& allignInfo, const u64 dataSize, RankSliceInfo& sliceInfoVec) override;
36 : HcclResult CalcRes(AlgTempResReq& tempResReq) override;
37 : HcclResult GetScatterStepInfo(u32 step, u32 nSteps, AicpuNHRStepInfo& stepInfo) const;
38 : uint64_t GetExpandedMode() const;
39 :
40 : private:
41 : HcclResult
42 : PreCopy(const TempFuncs& tempFuncs, const RankSliceInfo& sliceInfoVec, std::vector<InsQuePtr>& tempInsQues);
43 : HcclResult
44 : PostCopy(const TempFuncs& tempFuncs, const RankSliceInfo& sliceInfoVec, std::vector<InsQuePtr>& tempInsQues);
45 :
46 : HcclResult BatchTxRx(
47 : AicpuNHRStepInfo& stepInfo, const ResLinks& tempLinks, InsQuePtr& queue, const RankSliceInfo& sliceInfoVec);
48 : HcclResult BatchSend(
49 : AicpuNHRStepInfo& stepInfo, const ResLinks& tempLinks, InsQuePtr& queue, const RankSliceInfo& sliceInfoVec,
50 : BufferType memType, u32 memOffset) const;
51 : HcclResult BatchRecv(
52 : AicpuNHRStepInfo& stepInfo, const ResLinks& tempLinks, InsQuePtr& queue, const RankSliceInfo& sliceInfoVec,
53 : BufferType memType, u32 memOffset) const;
54 : HcclResult BatchSR(
55 : AicpuNHRStepInfo& stepInfo, const ResLinks& tempLinks, InsQuePtr& queue, const RankSliceInfo& sliceInfoVec,
56 : BufferType memType, u32 memOffset) const;
57 :
58 : HcclResult GetGatherStepInfo(std::vector<AicpuNHRStepInfo>& nhrSteps) const;
59 :
60 : // 主要搬运所用的Buffer
61 : BufferType mainBufferType_;
62 : u64 mainBufferBaseOffset_{0};
63 : };
64 :
65 : } // namespace Hccl
66 :
67 : #endif /* INS_TEMP_GATHER_NHR */
|