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_p2p_transport_req.h"
12 :
13 :
14 : namespace hccl {
15 0 : CalcP2PTransportReq::CalcP2PTransportReq(std::vector<std::vector<u32>> &subCommPlaneVector,
16 0 : std::vector<bool> &isBridgeVector, u32 userRank)
17 0 : : CalcTransportReqBase(subCommPlaneVector, isBridgeVector, userRank)
18 : {
19 0 : }
20 :
21 0 : CalcP2PTransportReq::~CalcP2PTransportReq()
22 : {
23 0 : }
24 :
25 0 : HcclResult CalcP2PTransportReq::CalcTransportRequest(const std::string &tag, TransportMemType inputMemType,
26 : TransportMemType outputMemType, const CommParaInfo &commParaInfo,
27 : std::vector<SingleSubCommTransport> &commTransport, u32 subUserRankRoot)
28 : {
29 0 : u32 planeSize = subCommPlaneVector_.size();
30 0 : commTransport.resize(planeSize);
31 :
32 0 : for (u32 planeIndex = 0; planeIndex < planeSize; planeIndex++) {
33 0 : u32 rankSize = subCommPlaneVector_[planeIndex].size();
34 0 : SingleSubCommTransport &subCommTransport = commTransport[planeIndex];
35 0 : subCommTransport.transportRequests.resize(rankSize);
36 :
37 0 : if (userRank_ == commParaInfo.peerUserRank) {
38 0 : HCCL_ERROR("[CalcP2PCommInfo]p2p dstRank_[%u] is not support to create link with itself", userRank_);
39 0 : return HCCL_E_PARA;
40 : }
41 0 : TransportRequest &tmpTransport = subCommTransport.transportRequests[0];
42 :
43 0 : tmpTransport.isValid = true;
44 0 : tmpTransport.localUserRank = userRank_;
45 0 : tmpTransport.remoteUserRank = commParaInfo.peerUserRank;
46 0 : tmpTransport.inputMemType = inputMemType;
47 0 : tmpTransport.outputMemType = outputMemType;
48 0 : HCCL_INFO("[CommFactory][CalcP2PCommInfo] param_.tag[%s] planeIndex[%u], localRank[%u]," \
49 : "remoteRank[%u], inputMemType[%d], outputMemType[%d]", tag.c_str(), planeIndex, userRank_,
50 : tmpTransport.remoteUserRank, inputMemType, outputMemType);
51 : }
52 0 : return HCCL_SUCCESS;
53 : }
54 :
55 : } // namespace hccl
|