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_ALL_GATHER_RING
12 : #define HCCLV2_TEMP_ALL_GATHER_RING
13 :
14 : #include "string_util.h"
15 :
16 : #include "alg_template_base_v2.h"
17 :
18 : namespace Hccl {
19 :
20 : class TempAllGatherRing : public AlgTemplateBase {
21 : public:
22 : explicit TempAllGatherRing(const RankId virtualRank, const u32 tempRankSize,
23 : const std::vector<std::vector<RankId>> &tempVTopo,
24 : const std::map<RankId, u32> &tempVirtRankMap);
25 : ~TempAllGatherRing() override;
26 :
27 0 : std::string Describe() const override
28 : {
29 0 : return StringFormat("Template of all gather ring with tempRankSize [%u].", tempRankSize_);
30 : }
31 :
32 : HcclResult GenPrimQue(const TempFuncs &tempFuncs, const RankSliceInfo &sliceInfoVec, const BuffInfo &buffInfo,
33 : const ResLinks &tempLinks, std::vector<PrimQuePtr> &tempPrimQues) override;
34 : using AlgTemplateBase::CalcSliceInfo;
35 : HcclResult CalcSliceInfo(const AllignInfo &allignInfo, const u64 dataSize, RankSliceInfo &sliceInfoVec) override;
36 : using AlgTemplateBase::CalcRes;
37 : HcclResult CalcRes(AlgTempResReq &tempResReq) override;
38 :
39 : private:
40 : HcclResult PreCopyOffload(const RankSliceInfo &sliceInfoVec, const bool forAllReduce,
41 : std::vector<PrimQuePtr> &tempPrimQues);
42 : HcclResult RunIndividualRing(const u32 queIdx, const RankSliceInfo &sliceInfoVec, const ResLinks &tempLinks,
43 : PrimQuePtr currPrimQue);
44 :
45 : u32 stepNum_ = 0;
46 : };
47 :
48 : } // namespace Hccl
49 :
50 : #endif // !HCCLV2_TEMP_ALL_GATHER_RING
|