LCOV - code coverage report
Current view: top level - legacy/ascend910/algorithm/base/communicator - calc_mesh_transport_req.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 94.3 % 35 33
Test Date: 2026-08-04 10:52:23 Functions: 100.0 % 4 4

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

Generated by: LCOV version 2.0-1