LCOV - code coverage report
Current view: top level - legacy/ascend910/algorithm/base/communicator/legacy - comm_p2p.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 38 0
Test Date: 2026-07-28 12:11:00 Functions: 0.0 % 4 0

            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 "comm_p2p.h"
      12              : 
      13              : namespace hccl {
      14            0 : CommP2P::CommP2P(const std::string &collectiveId, const u32 userRank,
      15              :     const u32 userRankSize, const u32 rank, const u32 rankSize, const TopoType topoFlag,
      16              :     const HcclDispatcher dispatcher, const std::unique_ptr<NotifyPool> &notifyPool,
      17              :     std::map<HcclIpAddress, HcclNetDevCtx> &netDevCtxMap,
      18              :     const IntraExchanger &exchanger, const std::vector<RankInfo> paraVector,
      19              :     const DeviceMem& inputMem, const DeviceMem& outputMem, const bool isUsedRdmaLevel0,
      20              :     const std::string &tag, const u32 dstUserRank, const NICDeployment nicDeployInner,
      21            0 :     const bool isHaveCpuRank, const bool useSuperPodMode)
      22              :     : CommBase(collectiveId, userRank, userRankSize, rank, rankSize, paraVector, topoFlag, dispatcher, notifyPool,
      23              :       netDevCtxMap, exchanger, inputMem, outputMem, isUsedRdmaLevel0, tag, nicDeployInner, false, false, false, INVALID_UINT, isHaveCpuRank,
      24              :       useSuperPodMode),
      25            0 :       dstUserRank_(dstUserRank)
      26              : {
      27            0 : }
      28              : 
      29            0 : CommP2P::~CommP2P()
      30              : {
      31            0 : }
      32              : 
      33            0 : HcclResult CommP2P::CalcLink()
      34              : {
      35            0 :     u32 dstRank = INVALID_VALUE_RANKID;
      36            0 :     HcclResult ret = GetRankByUserRank(dstUserRank_, dstRank);
      37            0 :     CHK_PRT_RET(ret != HCCL_SUCCESS, HCCL_ERROR("[Calc][Link]comm p2p dstRank[%u] is invalid", dstRank), HCCL_E_PARA);
      38              : 
      39            0 :     if (paraVector_.size() <= dstRank) {
      40            0 :         HCCL_ERROR("[Calc][Link]comm p2p dstRank[%u] is bigger than para_vector size[%llu]",
      41              :             dstRank, paraVector_.size());
      42            0 :         return HCCL_E_PARA;
      43              :     }
      44              : 
      45            0 :     if (paraVector_.size() <= rank_) {
      46            0 :         HCCL_ERROR("[Calc][Link]comm p2p rank[%u] is bigger than para_vector size[%llu]", rank_, paraVector_.size());
      47            0 :         return HCCL_E_PARA;
      48              :     }
      49              : 
      50              :     /* 校验建链可行性:
      51              :     服务器间devid满足:基于8取模值相同(devid相等) */
      52            0 :     bool isSupportP2P = false;
      53            0 :     if ((paraVector_[rank_].deviceType == DevType::DEV_TYPE_910) ||
      54            0 :         (paraVector_[rank_].deviceType == DevType::DEV_TYPE_910B) ||
      55            0 :         (paraVector_[rank_].deviceType == DevType::DEV_TYPE_910_93) ||
      56            0 :         (paraVector_[rank_].deviceType == DevType::DEV_TYPE_NOSOC)) {
      57            0 :         isSupportP2P = true;
      58            0 :     } else if (paraVector_[rank_].deviceType == DevType::DEV_TYPE_310P3) {
      59            0 :         isSupportP2P = (paraVector_[rank_].serverId == paraVector_[dstRank].serverId);
      60              :     } else {
      61            0 :         HCCL_ERROR("[Calc][Link]invalid device type[%d]", paraVector_[rank_].deviceType);
      62            0 :         return HCCL_E_PARA;
      63              :     }
      64            0 :     if (!isSupportP2P) {
      65            0 :         HCCL_ERROR("[Calc][Link]comm p2p rank[%u] devid[%d] serverId[%s] and dstRank[%u] devid[%d] serverId[%s] is "\
      66              :             "not support P2P", rank_, paraVector_[rank_].devicePhyId, paraVector_[rank_].serverId.c_str(),\
      67              :             dstRank, paraVector_[dstRank].devicePhyId, paraVector_[dstRank].serverId.c_str());
      68            0 :         return HCCL_E_PARA;
      69              :     }
      70              : 
      71            0 :     if (rank_ < dstRank) {
      72            0 :         ret = CalcLinksNum(MachineType::MACHINE_SERVER_TYPE, dstRank);
      73            0 :         CHK_PRT_RET(ret != HCCL_SUCCESS, HCCL_ERROR("[Calc][Link]comm p2p calc links num failed, type[%d], dstRank[%u]",
      74              :             static_cast<int32_t>(MachineType::MACHINE_SERVER_TYPE), dstRank), ret);
      75            0 :     } else if (rank_ > dstRank) {
      76            0 :         ret = CalcLinksNum(MachineType::MACHINE_CLIENT_TYPE, dstRank);
      77            0 :         CHK_PRT_RET(ret != HCCL_SUCCESS, HCCL_ERROR("[Calc][Link]comm p2p calc links num failed, type[%d], dstRank[%u]",
      78              :             static_cast<int32_t>(MachineType::MACHINE_CLIENT_TYPE), dstRank), ret);
      79              :     } else {
      80            0 :         HCCL_ERROR("[Calc][Link]comm p2p dstRank_[%u] is not support to create link with itself", dstRank);
      81            0 :         return HCCL_E_PARA;
      82              :     }
      83              : 
      84            0 :     return HCCL_SUCCESS;
      85              : }
      86              : }  // namespace hccl
        

Generated by: LCOV version 2.0-1