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(const RankId virtualRank, const u32 tempRankSize,
29 : 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(const TempFuncs &tempFuncs, const RankSliceInfo &sliceInfoVec, const BuffInfo &buffInfo,
39 : const ResLinks &tempLinks, std::vector<PrimQuePtr> &tempPrimQues) override;
40 :
41 : using AlgTemplateBase::CalcSliceInfo;
42 : HcclResult CalcSliceInfo(const AllignInfo &allignInfo, const bool forAllReduce, const u64 dataSize,
43 : RankSliceInfo &sliceInfoVec) override;
44 :
45 : using AlgTemplateBase::CalcRes;
46 : HcclResult CalcRes(const bool forAllReduce, AlgTempResReq &tempResReq, u32 &requiredScratchMultiplier) override;
47 :
48 : private:
49 : HcclResult CalcSliceInfoAllReduce(const AllignInfo &allignInfo, const u64 dataSize, RankSliceInfo &sliceInfoVec);
50 :
51 : HcclResult RunIndividualRing(const u32 queIdx, const bool &forAllReduce, const RankSliceInfo &sliceInfoVec,
52 : const ResLinks &tempLinks, PrimQuePtr currPrimQue);
53 :
54 : HcclResult PostCopyOffload(const RankSliceInfo &sliceInfoVec, std::vector<PrimQuePtr> &tempPrimQues);
55 :
56 : u32 stepNum_ = 0;
57 : };
58 :
59 : } // namespace Hccl
60 :
61 : #endif // !HCCLV2_TEMP_REDUCE_SCATTER_RING
|