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_REDUCE_SCATTER_NHR
12 : #define HCCLV2_INS_TEMP_REDUCE_SCATTER_NHR
13 :
14 : #include "string_util.h"
15 : #include "ins_temp_all_gather_nhr.h"
16 : #include "ins_alg_template_base.h"
17 : namespace Hccl {
18 :
19 : class InsTempReduceScatterNHR : public InsAlgTemplateBase {
20 : public:
21 : explicit InsTempReduceScatterNHR(
22 : const RankId virtualRank, const u32 tempRankSize, const std::vector<std::vector<RankId>>& tempVTopo,
23 : const std::map<RankId, u32>& tempVirtRankMap);
24 : ~InsTempReduceScatterNHR() override;
25 :
26 0 : std::string Describe() const override
27 : {
28 0 : return StringFormat("Template of reduce scatter NHR with tempRankSize [%u].", tempRankSize_);
29 : }
30 :
31 : HcclResult
32 : 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
37 : PreCopy(const TempFuncs& tempFuncs, const RankSliceInfo& sliceInfoVec, std::vector<InsQuePtr>& tempInsQues);
38 : HcclResult
39 : PostCopy(const TempFuncs& tempFuncs, const RankSliceInfo& sliceInfoVec, std::vector<InsQuePtr>& tempInsQues);
40 : HcclResult GetScratchBufferInfo(const uint64_t scratchBufferSize, DataType dataType) const;
41 : HcclResult GenExtIns(
42 : const TempFuncs& tempFuncs, const TemplateDataParams& tempAlgParams, const ResLinks& tempLinks,
43 : std::vector<InsQuePtr>& tempInsQues);
44 0 : u32 CalcScratchMultiple(const BufferType& inBufferTpye, const BufferType& outBufferTpye) const
45 : {
46 : (void)inBufferTpye;
47 : (void)outBufferTpye;
48 0 : HCCL_INFO("[InsTempReduceScatterNHR][CalcScratchMultiple] templateScratchMultiplier[%llu]", tempRankSize_);
49 0 : return tempRankSize_;
50 : }
51 :
52 : private:
53 : HcclResult MultiSliceLocalCopy(
54 : InsQuePtr& insQue, const std::vector<DataSlice>& srcList, const std::vector<DataSlice>& dstList) const;
55 : HcclResult
56 : RunReduceScatter(const RankSliceInfo& sliceInfoVec, const ResLinks& tempLinks, std::vector<InsQuePtr>& tempInsQues);
57 : HcclResult GetStepInfoList(std::vector<AicpuNHRStepInfo>& stepInfoList);
58 : RankId GetRankFromMap(const u32 rankIdx);
59 : HcclResult LocalDataCopy(std::vector<InsQuePtr>& tempInsQues, const TempFuncs& tempFuncs, u32 linkIdx);
60 : HcclResult RunNHR(std::vector<InsQuePtr>& tempInsQues, u32 linkIdx);
61 : HcclResult PostLocalCopy(std::vector<InsQuePtr>& tempInsQues, u32 linkIdx);
62 : TemplateDataParams tempAlgParams_;
63 : ResLinks tempLinks_;
64 : vector<u64> processSize_{0};
65 : vector<u64> linkSliceOffsetVec_{0};
66 : };
67 :
68 : } // namespace Hccl
69 :
70 : #endif // !HCCLV2_INS_TEMP_REDUCE_SCATTER_NHR
|