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

Generated by: LCOV version 2.0-1