LCOV - code coverage report
Current view: top level - legacy/ascend910/algorithm/base/communicator - calc_hd_transport_req.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 94.7 % 38 36
Test Date: 2026-07-28 12:11:00 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 "alg_template_base_pub.h"
      12              : #include "calc_hd_transport_req.h"
      13              : 
      14              : namespace hccl {
      15           34 : CalcHDTransportReq::CalcHDTransportReq(std::vector<std::vector<u32>> &subCommPlaneVector,
      16           34 :     std::vector<bool> &isBridgeVector, u32 userRank)
      17           34 :     : CalcTransportReqBase(subCommPlaneVector, isBridgeVector, userRank)
      18              : {
      19           34 : }
      20              : 
      21           68 : CalcHDTransportReq::~CalcHDTransportReq()
      22              : {
      23           68 : }
      24              : 
      25           34 : HcclResult CalcHDTransportReq::CalcTransportRequest(const std::string &tag, TransportMemType inputMemType,
      26              :     TransportMemType outputMemType, const CommParaInfo &commParaInfo,
      27              :     std::vector<SingleSubCommTransport> &commTransport, u32 subUserRankRoot)
      28              : {
      29           34 :     u32 ringSize = subCommPlaneVector_.size();
      30           34 :     commTransport.resize(ringSize);
      31              : 
      32           82 :     for (u32 ringIndex = 0; ringIndex < ringSize; ringIndex++) {
      33           76 :         if (commParaInfo.commPlane == COMM_LEVEL1 && !isBridgeVector_[ringIndex]) {
      34           42 :             continue; // 跳出本次循环
      35              :         }
      36              : 
      37           34 :         u32 rank = GetSubCollectiveRank(subCommPlaneVector_[ringIndex]);
      38           34 :         if (rank == INVALID_VALUE_RANKID) {
      39            0 :             continue;
      40              :         }
      41              : 
      42           34 :         u32 rankSize = subCommPlaneVector_[ringIndex].size();
      43           34 :         SingleSubCommTransport &subCommTransport = commTransport[ringIndex];
      44           34 :         subCommTransport.transportRequests.resize(rankSize);
      45              :         // 只有一张卡时不需要建链
      46           34 :         if (rankSize == HCCL_RANK_SIZE_EQ_ONE) {
      47           28 :             HCCL_INFO("comm base needn't to create links, rankSize_[%u].", rankSize);
      48           28 :             return HCCL_SUCCESS;
      49              :         }
      50              : 
      51            6 :         u32 subRoot = INVALID_VALUE_RANKID;
      52            6 :         if (subUserRankRoot != INVALID_VALUE_RANKID) {
      53            0 :             CHK_RET(GetRankByUserRank(subCommPlaneVector_[ringIndex], subUserRankRoot, subRoot));
      54              :         }
      55              : 
      56              :         std::vector<bool> linkRelation =  AlgTemplateBase::CalcLinksRelation(rank, rankSize, subRoot,
      57            6 :             HalvingDoublingType::RECURSIVE_HALVING_DOUBLING);
      58              : 
      59           18 :         for (u32 rankIndex = 0; rankIndex < rankSize; rankIndex++) {
      60           12 :             TransportRequest &tmpTransport = subCommTransport.transportRequests[rankIndex];
      61           12 :             if (linkRelation[rankIndex] == true) {
      62            6 :                 tmpTransport.isValid = true;
      63            6 :                 tmpTransport.localUserRank  = userRank_;
      64            6 :                 tmpTransport.remoteUserRank = subCommPlaneVector_[ringIndex][rankIndex];
      65            6 :                 tmpTransport.inputMemType = inputMemType;
      66            6 :                 tmpTransport.outputMemType = outputMemType;
      67            6 :                 HCCL_INFO("[CommFactory][CalcHDCommInfo] param_.tag[%s] ringIndex[%u], localRank[%u], " \
      68              :                     "remoteRank[%u], inputMemType[%d], outputMemType[%d]", tag.c_str(), ringIndex, userRank_,
      69              :                     tmpTransport.remoteUserRank, inputMemType, outputMemType);
      70              :             } else {
      71            6 :                 tmpTransport.isValid = false;
      72              :             }
      73              :         }
      74            6 :         subCommTransport.supportDataReceivedAck = true;
      75            6 :     }
      76            6 :     return HCCL_SUCCESS;
      77              : }
      78              : 
      79              : }  // namespace hccl
        

Generated by: LCOV version 2.0-1