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(
23 : const RankId virtualRank, const u32 tempRankSize, 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
33 : Run(const TempFuncs& tempFuncs, const RankSliceInfo& sliceInfoVec, const BuffInfo& buffInfo,
34 : const ResLinks& tempLinks, std::vector<InsQuePtr>& tempInsQues) override;
35 : HcclResult CalcResDetour(const RankGraph* rankGraph, AlgTempResReq& tempResReq) override;
36 : HcclResult CalcResDetour(ConnectedLinkMgr* linkMgr, AlgTempResReq& tempResReq) override;
37 : HcclResult CalcSliceInfo(const AllignInfo& allignInfo, const u64 dataSize, RankSliceInfo& sliceInfoVec) override;
38 :
39 : private:
40 : void GetAddrInfo(
41 : const TempFuncs& tempFuncs, const RankSliceInfo& sliceInfoVec, uint64_t& inputAddr, uint64_t& outputAddr,
42 : uint64_t& offset);
43 : void CalcDetourOffset(uint64_t sliceSize, uint64_t& tailOffset, uint64_t& tailSize, uint64_t& loopIterNum);
44 : void ProcessLinks(std::vector<LinkData>& links, const ResLinks& tempLinks) const;
45 :
46 : uint64_t detourPathNum_{0}; // 到每个对端有几个绕路路径
47 : uint64_t pathNumPerPeer_{0};
48 : std::vector<uint64_t> lengths_;
49 : uint64_t singleTransportSize_{0};
50 : };
51 :
52 : } // namespace Hccl
53 :
54 : #endif // HCCLV2_CCU_TEMP_ALL_GATHER_MESH_1D_H_
|