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_CCU_TEMP_ALL_GATHER_MESH_DETOUR_1D_H
12 : #define HCCLV2_CCU_TEMP_ALL_GATHER_MESH_DETOUR_1D_H
13 :
14 : #include "string_util.h"
15 : #include "ccu_alg_template_base.h"
16 : #include "ccu_instruction_all_gather_mesh1d_detour.h"
17 :
18 : namespace Hccl {
19 :
20 : class CcuTempAllGatherMeshDetour1D : public CcuAlgTemplateBase {
21 : public:
22 : explicit CcuTempAllGatherMeshDetour1D(const RankId virtualRank, const u32 tempRankSize,
23 : const std::vector<std::vector<RankId>> &tempVTopo,
24 : const std::map<RankId, u32> &tempVirtRankMap);
25 : ~CcuTempAllGatherMeshDetour1D() override;
26 :
27 0 : std::string Describe() const override
28 : {
29 0 : return StringFormat("Template of all gather ccu mesh Detour 1D with tempRankSize [%u].", tempRankSize_);
30 : }
31 :
32 : HcclResult Run(const TempFuncs &tempFuncs, const RankSliceInfo &sliceInfoVec, const BuffInfo &buffInfo,
33 : const ResLinks &tempLinks, std::vector<InsQuePtr> &tempInsQues) override;
34 : HcclResult CalcResDetour(const RankGraph *rankGraph, AlgTempResReq &tempResReq) override;
35 : HcclResult CalcResDetour(ConnectedLinkMgr *linkMgr, AlgTempResReq &tempResReq) override;
36 : HcclResult CalcSliceInfo(const AllignInfo &allignInfo, const u64 dataSize, RankSliceInfo &sliceInfoVec) override;
37 : private:
38 : void GetAddrInfo(const TempFuncs &tempFuncs, const RankSliceInfo &sliceInfoVec,
39 : uint64_t &inputAddr, uint64_t &outputAddr, uint64_t &offset);
40 : void CalcDetourOffset(uint64_t sliceSize, uint64_t &tailOffset, uint64_t &tailSize, uint64_t &loopIterNum);
41 : void ProcessLinks(std::vector<LinkData> &links, const ResLinks &tempLinks) const;
42 :
43 : uint64_t detourPathNum_{0}; // 到每个对端有几个绕路路径
44 : uint64_t pathNumPerPeer_{0};
45 : std::vector<uint64_t> lengths_;
46 : uint64_t singleTransportSize_{0};
47 : };
48 :
49 : } // namespace Hccl
50 :
51 : #endif // HCCLV2_CCU_TEMP_ALL_GATHER_MESH_1D_H_
|