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 : #include "calc_ahc_transport_req.h"
12 :
13 : namespace hccl {
14 0 : CalcAHCTransportReq::CalcAHCTransportReq(
15 : std::vector<std::vector<u32>>& subCommPlaneVector, std::vector<bool>& isBridgeVector, u32 userRank,
16 : std::vector<std::vector<std::vector<u32>>>& globalSubGroups, std::map<AHCConcOpType, TemplateType>& ahcAlgOption,
17 0 : std::unordered_map<u32, bool>& isUsedRdmaMap)
18 : : CalcAHCTransportReqBase(
19 0 : subCommPlaneVector, isBridgeVector, userRank, globalSubGroups, ahcAlgOption, isUsedRdmaMap)
20 0 : {}
21 :
22 0 : CalcAHCTransportReq::~CalcAHCTransportReq() {}
23 :
24 0 : HcclResult CalcAHCTransportReq::DisposeSubGroups(u32 rank)
25 : {
26 0 : std::vector<std::vector<u32>> level1SubGroups;
27 0 : CommAHCBaseInfo::DisposeSubGroups(rank, globalSubGroups_, subGroups_, level1SubGroups);
28 0 : return HCCL_SUCCESS;
29 0 : }
30 :
31 0 : HcclResult CalcAHCTransportReq::CalcDstRanks(u32 rank, std::set<u32>& dstRanks, u32 ringIndex)
32 : {
33 : (void)ringIndex;
34 :
35 : // 获取 rank 对应分组信息
36 0 : DisposeSubGroups(rank);
37 :
38 : // commAHCBaseInfo_ 初始化
39 0 : CHK_RET(CommAHCInfoInit(subGroups_));
40 :
41 : // 计算 AHC建链的目的dstRanks
42 0 : commAHCBaseInfo_->CalcDstRanks(rank, dstRanks);
43 :
44 0 : return HCCL_SUCCESS;
45 : }
46 :
47 0 : HcclResult CalcAHCTransportReq::CommAHCInfoInit(std::vector<std::vector<u32>>& subGroups)
48 : {
49 0 : commAHCBaseInfo_.reset(new (std::nothrow) CommAHCAlignInfo(subGroups));
50 0 : CHK_SMART_PTR_NULL(commAHCBaseInfo_);
51 0 : CHK_RET(commAHCBaseInfo_->Init(opType_, ahcAlgOption_));
52 0 : return HCCL_SUCCESS;
53 : }
54 :
55 : } // namespace hccl
|