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_hccs_plus_sio_transport_req.h"
12 :
13 : namespace hccl {
14 0 : CalcHccsPlusSioTransportReq::CalcHccsPlusSioTransportReq(
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 : CalcHccsPlusSioTransportReq::~CalcHccsPlusSioTransportReq() {}
20 :
21 0 : HcclResult CalcHccsPlusSioTransportReq::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 ringSize = 2;
27 0 : commTransport.resize(ringSize);
28 :
29 0 : for (u32 ringIndex = 0; ringIndex < ringSize; ringIndex++) {
30 0 : if (commParaInfo.commPlane == COMM_LEVEL1 && !isBridgeVector_.empty() && !isBridgeVector_[0]) {
31 0 : continue; // 跳出本次循环
32 : }
33 0 : CHK_PRT_RET(
34 : subCommPlaneVector_.empty(),
35 : HCCL_ERROR("[CalcHccsPlusSioTransportReq][CalcTransportRequest] "
36 : "the vector named subCommPlaneVector_ is empty."),
37 : HCCL_E_NOT_FOUND);
38 0 : u32 rank = GetSubCollectiveRank(subCommPlaneVector_[0]);
39 0 : if (rank == INVALID_VALUE_RANKID) {
40 0 : continue;
41 : }
42 :
43 0 : u32 rankSize = subCommPlaneVector_[0].size();
44 0 : SingleSubCommTransport& subCommTransport = commTransport[ringIndex];
45 0 : subCommTransport.transportRequests.resize(rankSize);
46 : // 只有一张卡时不需要建链
47 0 : if (rankSize == HCCL_RANK_SIZE_EQ_ONE) {
48 0 : HCCL_INFO("comm base needn't to create links, rankSize_[%u].", rankSize);
49 0 : return HCCL_SUCCESS;
50 : }
51 :
52 0 : HCCL_DEBUG("[CalcHccsPlusSioTransportReq][CalcTransportRequest]rankSize is %u", rankSize);
53 0 : for (u32 rankIndex = 0; rankIndex < rankSize; rankIndex++) {
54 0 : TransportRequest& tmpTransport = subCommTransport.transportRequests[rankIndex];
55 0 : if (rankIndex != rank) {
56 0 : tmpTransport.isValid = true;
57 0 : tmpTransport.localUserRank = userRank_;
58 0 : tmpTransport.remoteUserRank = subCommPlaneVector_[0][rankIndex];
59 0 : tmpTransport.inputMemType = inputMemType;
60 0 : tmpTransport.outputMemType = outputMemType;
61 0 : tmpTransport.linkType = (ringIndex == 0) ? TransportLinkType::HCCS : TransportLinkType::SIO;
62 0 : HCCL_INFO(
63 : "[CommFactory][CalcHccsPlusSioCommInfo] param_.tag[%s] ringIndex[%u], localRank[%u], "
64 : "remoteRank[%u], inputMemType[%d], outputMemType[%d], linkType[%d]",
65 : tag.c_str(), ringIndex, userRank_, tmpTransport.remoteUserRank, inputMemType, outputMemType,
66 : tmpTransport.linkType);
67 : } else {
68 0 : tmpTransport.isValid = false;
69 0 : continue;
70 : }
71 : }
72 : }
73 0 : return HCCL_SUCCESS;
74 : }
75 :
76 : } // namespace hccl
|