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

Generated by: LCOV version 2.0-1