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

Generated by: LCOV version 2.0-1