LCOV - code coverage report
Current view: top level - base_comm/resources/endpoints - ub_mem_endpoint.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 64.7 % 34 22
Test Date: 2026-08-17 10:19:35 Functions: 66.7 % 12 8

            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              : #include "ub_mem_endpoint.h"
      11              : #include "log.h"
      12              : #include "hccl/hccl_res.h"
      13              : #include "adapter_rts_common.h"
      14              : #include "server_socket_mgr.h"
      15              : #include "ub_mem.h"
      16              : #include "proc_reged_mem_mgr_cache.h"
      17              : #include "hccl_mem_defs.h"
      18              : 
      19              : namespace hcomm {
      20           17 : UbMemEndpoint::UbMemEndpoint(const EndpointDesc& endpointDesc) : Endpoint(endpointDesc) {}
      21              : 
      22           34 : UbMemEndpoint::~UbMemEndpoint() noexcept { ProcRegedMemMgrCache::GetInstance().Release(cacheKey_); }
      23              : 
      24           17 : HcclResult UbMemEndpoint::Init()
      25              : {
      26           17 :     Hccl::IpAddress ipAddr{};
      27           17 :     CHK_RET(CommAddrToIpAddress(endpointDesc_.commAddr, ipAddr));
      28              : 
      29           17 :     s32 devId = 0;
      30           17 :     CHK_RET(hrtGetDevice(&devId));
      31           17 :     u32 devPhyId = 0;
      32           17 :     CHK_RET(hrtGetDevicePhyIdByIndex(devId, devPhyId));
      33              : 
      34           17 :     cacheKey_ = MemMgrCacheKey{devPhyId, COMM_PROTOCOL_UB_MEM, ipAddr, LocTypeToPortType(endpointDesc_.loc.locType)};
      35           17 :     auto& cache = ProcRegedMemMgrCache::GetInstance();
      36           24 :     EXCEPTION_CATCH(
      37              :         regedMemMgr_ = cache.GetOrCreate(
      38              :             cacheKey_,
      39              :             []() {
      40              :                 return std::make_shared<UbMemRegedMemMgr>();
      41              :             }),
      42              :         return HCCL_E_INTERNAL);
      43              : 
      44           17 :     return HcclResult::HCCL_SUCCESS;
      45              : }
      46              : 
      47           20 : HcclResult UbMemEndpoint::ServerSocketListen(const uint32_t port)
      48              : {
      49              :     (void)port;
      50           20 :     HCCL_INFO("UbMemEndpoint ServerSocketListen is not supported");
      51           20 :     return HCCL_SUCCESS;
      52              : }
      53              : 
      54           15 : HcclResult UbMemEndpoint::RegisterMemory(HcommMem mem, const char* memTag, void** memHandle)
      55              : {
      56           15 :     CHK_RET(this->regedMemMgr_->RegisterMemory(mem, memTag, memHandle));
      57           12 :     return HCCL_SUCCESS;
      58              : }
      59              : 
      60           15 : HcclResult UbMemEndpoint::UnregisterMemory(void* memHandle)
      61              : {
      62           15 :     CHK_RET(this->regedMemMgr_->UnregisterMemory(memHandle));
      63           12 :     return HCCL_SUCCESS;
      64              : }
      65              : 
      66            0 : HcclResult UbMemEndpoint::MemoryExport(void* memHandle, void** memDesc, uint32_t* memDescLen)
      67              : {
      68            0 :     HCCL_INFO("UbMemEndpoint MemoryExport is not supported");
      69            0 :     return HCCL_SUCCESS;
      70              : }
      71              : 
      72            0 : HcclResult UbMemEndpoint::MemoryImport(const void* memDesc, uint32_t descLen, HcommMem* outMem)
      73              : {
      74            0 :     HCCL_INFO("UbMemEndpoint MemoryImport is not supported");
      75            0 :     return HCCL_SUCCESS;
      76              : }
      77              : 
      78            0 : HcclResult UbMemEndpoint::MemoryUnimport(const void* memDesc, uint32_t descLen)
      79              : {
      80            0 :     HCCL_INFO("UbMemEndpoint MemoryUnimport is not supported");
      81            0 :     return HCCL_SUCCESS;
      82              : }
      83              : 
      84            0 : HcclResult UbMemEndpoint::GetAllMemHandles(void** memHandles, uint32_t* memHandleNum)
      85              : {
      86            0 :     HCCL_INFO("UbMemEndpoint GetAllMemHandles is not supported");
      87            0 :     return HCCL_SUCCESS;
      88              : }
      89              : } // namespace hcomm
        

Generated by: LCOV version 2.0-1