LCOV - code coverage report
Current view: top level - base_comm/resources/endpoints - ubg_endpoint.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 91.3 % 23 21
Test Date: 2026-08-04 10:52:23 Functions: 100.0 % 2 2

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2026 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 "ubg_endpoint.h"
      12              : #include "endpoint_mgr.h"
      13              : #include "log.h"
      14              : #include "hccl/hccl_res.h"
      15              : #include "urma_mem.h"
      16              : #include "adapter_rts_common.h"
      17              : 
      18              : namespace hcomm {
      19              : 
      20            2 : UbgEndpoint::UbgEndpoint(const EndpointDesc &endpointDesc)
      21            2 :     : UboeUbgEndpointHelper(endpointDesc)
      22              : {
      23            2 : }
      24              : 
      25            2 : HcclResult UbgEndpoint::Init()
      26              : {
      27            2 :     HCCL_INFO("[%s] localEndpoint protocol[%d]", __func__, endpointDesc_.protocol);
      28              : 
      29            2 :     DevType deviceType = DevType::DEV_TYPE_COUNT;
      30            2 :     CHK_RET(hrtGetDeviceType(deviceType));
      31            2 :     if (deviceType != DevType::DEV_TYPE_950 && deviceType != DevType::DEV_TYPE_960) {
      32            0 :         HCCL_ERROR("[%s] UBG protocol only support DEV_TYPE_950/960, current deviceType=%d",
      33              :             __func__, static_cast<int>(deviceType));
      34            0 :         return HCCL_E_NOT_SUPPORT;
      35              :     }
      36              : 
      37              :     // UBG 直接从 EID type CommAddr 获取地址,不做 IP→EID 转换
      38            2 :     Hccl::IpAddress eidAddr{};
      39            2 :     CHK_RET(CommAddrToIpAddress(endpointDesc_.commAddr, eidAddr));
      40              : 
      41              :     s32 deviceLogicId;
      42              :     u32 devPhyId;
      43            2 :     CHK_RET(hrtGetDevice(&deviceLogicId));
      44            2 :     CHK_RET(hrtGetDevicePhyIdByIndex(static_cast<u32>(deviceLogicId), devPhyId));
      45            2 :     endpointDesc_.loc.device.devPhyId = devPhyId;
      46              : 
      47            2 :     Hccl::HccpHdcManager::GetInstance().Init(deviceLogicId);
      48              :     // UBG 直接用 EID 地址获取 rdmaHandle,不做 IP→EID 查询
      49            2 :     auto &rdmaHandleMgr = Hccl::RdmaHandleManager::GetInstance();
      50            2 :     EXCEPTION_CATCH(ctxHandle_ = static_cast<void *>(rdmaHandleMgr.GetByIp(endpointDesc_.loc.device.devPhyId, eidAddr)), 
      51              :         return HCCL_E_PARA);
      52            2 :     CHK_PTR_NULL(ctxHandle_);
      53            2 :     HCCL_INFO("%s success, devPhyId[%u], eidAddr[%s], ctxHandle[%p]",
      54              :         __func__, devPhyId, eidAddr.Describe().c_str(), ctxHandle_);
      55              : 
      56            2 :     EXCEPTION_CATCH(regedMemMgr_ = std::make_unique<UbRegedMemMgr>(), return HCCL_E_INTERNAL);
      57            2 :     regedMemMgr_->rdmaHandle_ = ctxHandle_;
      58              : 
      59            2 :     return HcclResult::HCCL_SUCCESS;
      60              : }
      61              : 
      62              : }
        

Generated by: LCOV version 2.0-1