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