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(const RankId virtualRank, const u32 tempRankSize,
32 : 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 Run(const TempFuncs &tempFuncs, const RankSliceInfo &sliceInfoVec, const BuffInfo &buffInfo,
42 : const ResLinks &tempLinks, std::vector<InsQuePtr> &tempInsQues) override;
43 : HcclResult CalcResDetour(const RankGraph *rankGraph, AlgTempResReq &tempResReq) override;
44 : HcclResult CalcResDetour(ConnectedLinkMgr *linkMgr, AlgTempResReq &tempResReq) override;
45 : HcclResult CalcSliceInfo(const AllignInfo &allignInfo, const u64 dataSize, RankSliceInfo &sliceInfoVec) override;
46 : // init reduceInfo
47 : void InitReduceInfo(const ReduceOp &reduceOp, const DataType &dataType);
48 :
49 : private:
50 : void GetAddrInfo(const TempFuncs &tempFuncs, uint64_t &inputAddr, uint64_t &outputAddr);
51 : void CalcDetourOffset(uint64_t sliceSize, uint64_t &tailOffset, uint64_t &tailSize, uint64_t &iterNum);
52 : void ProcessLinks(std::vector<LinkData> &links, const ResLinks &tempLinks) const;
53 : ReduceOp reduceOp_;
54 : DataType dataType_;
55 : uint64_t detourPathNum_{0}; // 到每个对端有几个绕路路径
56 : uint64_t pathNumPerPeer_{0};
57 : std::vector<uint64_t> lengths_;
58 : uint64_t singleTransportSize_{0};
59 : };
60 : }
61 : #endif // HCCLV2_CCU_TEMP_ALL_REDUCE_MESH_DETOUR_1D_H_
|