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_mesh_transport_req.h"
12 :
13 : namespace hccl {
14 61 : CalcMeshTransportReq::CalcMeshTransportReq(
15 61 : std::vector<std::vector<u32>>& subCommPlaneVector, std::vector<bool>& isBridgeVector, u32 userRank)
16 61 : : CalcTransportReqBase(subCommPlaneVector, isBridgeVector, userRank)
17 59 : {}
18 :
19 118 : CalcMeshTransportReq::~CalcMeshTransportReq() {}
20 :
21 52 : HcclResult CalcMeshTransportReq::CalcTransportRequest(
22 : const std::string& tag, TransportMemType inputMemType, TransportMemType outputMemType,
23 : const CommParaInfo& commParaInfo, std::vector<SingleSubCommTransport>& commTransport, u32 subUserRankRoot)
24 : {
25 52 : u32 ringSize = subCommPlaneVector_.size();
26 : // 910B非确定性计算场景,server内MESH组网只需要创建一个commbase平面
27 52 : if (commParaInfo.meshSinglePlane == true) {
28 35 : ringSize = 1;
29 : }
30 52 : commTransport.resize(ringSize);
31 :
32 136 : for (u32 ringIndex = 0; ringIndex < ringSize; ringIndex++) {
33 87 : if (commParaInfo.commPlane == COMM_LEVEL1 && !isBridgeVector_[ringIndex]) {
34 0 : continue; // 跳出本次循环
35 : }
36 :
37 87 : u32 rank = GetSubCollectiveRank(subCommPlaneVector_[ringIndex]);
38 88 : if (rank == INVALID_VALUE_RANKID) {
39 0 : continue;
40 : }
41 :
42 88 : u32 rankSize = subCommPlaneVector_[ringIndex].size();
43 87 : SingleSubCommTransport& subCommTransport = commTransport[ringIndex];
44 89 : subCommTransport.transportRequests.resize(rankSize);
45 : // 只有一张卡时不需要建链
46 83 : HCCL_DEBUG("[CalcMeshTransportReq]Calc for transportRequest");
47 92 : if (rankSize == HCCL_RANK_SIZE_EQ_ONE) {
48 13 : HCCL_INFO("comm base needn't to create links, rankSize_[%u].", rankSize);
49 13 : return HCCL_SUCCESS;
50 : }
51 :
52 394 : for (u32 rankIndex = 0; rankIndex < rankSize; rankIndex++) {
53 315 : TransportRequest& tmpTransport = subCommTransport.transportRequests[rankIndex];
54 314 : if (rankIndex != rank) {
55 234 : tmpTransport.isValid = true;
56 234 : tmpTransport.localUserRank = userRank_;
57 234 : tmpTransport.remoteUserRank = subCommPlaneVector_[ringIndex][rankIndex];
58 232 : tmpTransport.inputMemType = inputMemType;
59 232 : tmpTransport.outputMemType = outputMemType;
60 232 : HCCL_INFO(
61 : "[CommFactory][CalcMeshCommInfo] param_.tag[%s] ringIndex[%u], localRank[%u], "
62 : "remoteRank[%u], inputMemType[%d], outputMemType[%d]",
63 : tag.c_str(), ringIndex, userRank_, tmpTransport.remoteUserRank, inputMemType, outputMemType);
64 : } else {
65 80 : tmpTransport.isValid = false;
66 : }
67 : }
68 : }
69 49 : return HCCL_SUCCESS;
70 : }
71 :
72 : } // namespace hccl
|