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_REDUCE_MESH_DETOUR_1D_H_
12 : #define HCCLV2_CCU_TEMP_ALL_REDUCE_MESH_DETOUR_1D_H_
13 :
14 : #include <vector>
15 : #include <map>
16 : #include <string>
17 : #include <hccl/hccl_types.h>
18 : #include "ccu_instruction_all_reduce_mesh1d_detour.h"
19 : #include "reduce_op.h"
20 : #include "hccl/base.h"
21 : #include "types/types.h"
22 : #include "string_util.h"
23 : #include "data_type.h"
24 : #include "template_utils.h"
25 : #include "ccu_alg_template_base.h"
26 :
27 : namespace Hccl {
28 :
29 : class CcuTempAllReduceMeshDetour1D : public CcuAlgTemplateBase {
30 : public:
31 : explicit CcuTempAllReduceMeshDetour1D(
32 : const RankId virtualRank, const u32 tempRankSize, const std::vector<std::vector<RankId>>& tempVTopo,
33 : const std::map<RankId, u32>& tempVirtRankMap);
34 : ~CcuTempAllReduceMeshDetour1D() override;
35 :
36 0 : std::string Describe() const override
37 : {
38 0 : return StringFormat("Template of All Reduce ccu mesh 1D detour with tempRankSize [%u].", tempRankSize_);
39 : }
40 :
41 : HcclResult
42 : Run(const TempFuncs& tempFuncs, const RankSliceInfo& sliceInfoVec, const BuffInfo& buffInfo,
43 : const ResLinks& tempLinks, std::vector<InsQuePtr>& tempInsQues) override;
44 : HcclResult CalcResDetour(const RankGraph* rankGraph, AlgTempResReq& tempResReq) override;
45 : HcclResult CalcResDetour(ConnectedLinkMgr* linkMgr, AlgTempResReq& tempResReq) override;
46 : HcclResult CalcSliceInfo(const AllignInfo& allignInfo, const u64 dataSize, RankSliceInfo& sliceInfoVec) override;
47 : // init reduceInfo
48 : void InitReduceInfo(const ReduceOp& reduceOp, const DataType& dataType);
49 :
50 : private:
51 : void GetAddrInfo(const TempFuncs& tempFuncs, uint64_t& inputAddr, uint64_t& outputAddr);
52 : void CalcDetourOffset(uint64_t sliceSize, uint64_t& tailOffset, uint64_t& tailSize, uint64_t& iterNum);
53 : void ProcessLinks(std::vector<LinkData>& links, const ResLinks& tempLinks) const;
54 : ReduceOp reduceOp_;
55 : DataType dataType_;
56 : uint64_t detourPathNum_{0}; // 到每个对端有几个绕路路径
57 : uint64_t pathNumPerPeer_{0};
58 : std::vector<uint64_t> lengths_;
59 : uint64_t singleTransportSize_{0};
60 : };
61 : } // namespace Hccl
62 : #endif // HCCLV2_CCU_TEMP_ALL_REDUCE_MESH_DETOUR_1D_H_
|