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_TEMP_REDUCE_SCATTER_RING
12 : #define HCCLV2_TEMP_REDUCE_SCATTER_RING
13 : #include <vector>
14 : #include <map>
15 : #include <string>
16 : #include <hccl/hccl_types.h>
17 :
18 : #include "hccl/base.h"
19 : #include "types/types.h"
20 : #include "string_util.h"
21 : #include "template_utils.h"
22 : #include "alg_template_base_v2.h"
23 :
24 : namespace Hccl {
25 :
26 : class TempReduceScatterRing : public AlgTemplateBase {
27 : public:
28 : explicit TempReduceScatterRing(
29 : const RankId virtualRank, const u32 tempRankSize, const std::vector<std::vector<RankId>>& tempVTopo,
30 : const std::map<RankId, u32>& tempVirtRankMap);
31 : ~TempReduceScatterRing() override;
32 :
33 0 : std::string Describe() const override
34 : {
35 0 : return StringFormat("Template of reduce scatter ring with tempRankSize [%u].", tempRankSize_);
36 : }
37 :
38 : HcclResult GenPrimQue(
39 : const TempFuncs& tempFuncs, const RankSliceInfo& sliceInfoVec, const BuffInfo& buffInfo,
40 : const ResLinks& tempLinks, std::vector<PrimQuePtr>& tempPrimQues) override;
41 :
42 : using AlgTemplateBase::CalcSliceInfo;
43 : HcclResult CalcSliceInfo(
44 : const AllignInfo& allignInfo, const bool forAllReduce, const u64 dataSize,
45 : RankSliceInfo& sliceInfoVec) override;
46 :
47 : using AlgTemplateBase::CalcRes;
48 : HcclResult CalcRes(const bool forAllReduce, AlgTempResReq& tempResReq, u32& requiredScratchMultiplier) override;
49 :
50 : private:
51 : HcclResult CalcSliceInfoAllReduce(const AllignInfo& allignInfo, const u64 dataSize, RankSliceInfo& sliceInfoVec);
52 :
53 : HcclResult RunIndividualRing(
54 : const u32 queIdx, const bool& forAllReduce, const RankSliceInfo& sliceInfoVec, const ResLinks& tempLinks,
55 : PrimQuePtr currPrimQue);
56 :
57 : HcclResult PostCopyOffload(const RankSliceInfo& sliceInfoVec, std::vector<PrimQuePtr>& tempPrimQues);
58 :
59 : u32 stepNum_ = 0;
60 : };
61 :
62 : } // namespace Hccl
63 :
64 : #endif // !HCCLV2_TEMP_REDUCE_SCATTER_RING
|