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-25 19:18:03 Functions: 60.0 % 10 6

            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           17 : HcclResult UbMemEndpoint::Init()
      24              : {
      25           17 :     Hccl::IpAddress ipAddr{};
      26           17 :     CHK_RET(CommAddrToIpAddress(endpointDesc_.commAddr, ipAddr));
      27              : 
      28           17 :     s32 devId = 0;
      29           17 :     CHK_RET(hrtGetDevice(&devId));
      30           17 :     u32 devPhyId = 0;
      31           17 :     CHK_RET(hrtGetDevicePhyIdByIndex(devId, devPhyId));
      32              : 
      33           17 :     MemMgrCacheKey key{devPhyId, COMM_PROTOCOL_UB_MEM, ipAddr, LocTypeToPortType(endpointDesc_.loc.locType)};
      34            7 :     auto createMgr = []() {
      35            7 :         return std::make_shared<UbMemRegedMemMgr>();
      36              :     };
      37           17 :     CHK_RET(AttachCache(key, createMgr));
      38              : 
      39           17 :     return HcclResult::HCCL_SUCCESS;
      40              : }
      41              : 
      42           20 : HcclResult UbMemEndpoint::ServerSocketListen(const uint32_t port)
      43              : {
      44              :     (void)port;
      45           20 :     HCCL_INFO("UbMemEndpoint ServerSocketListen is not supported");
      46           20 :     return HCCL_SUCCESS;
      47              : }
      48              : 
      49           15 : HcclResult UbMemEndpoint::RegisterMemory(HcommMem mem, const char* memTag, void** memHandle)
      50              : {
      51           15 :     CHK_RET(this->regedMemMgr_->RegisterMemory(mem, memTag, memHandle));
      52           12 :     return HCCL_SUCCESS;
      53              : }
      54              : 
      55           15 : HcclResult UbMemEndpoint::UnregisterMemory(void* memHandle)
      56              : {
      57           15 :     CHK_RET(this->regedMemMgr_->UnregisterMemory(memHandle));
      58           12 :     return HCCL_SUCCESS;
      59              : }
      60              : 
      61            0 : HcclResult UbMemEndpoint::MemoryExport(
      62              :     [[maybe_unused]] void* memHandle, [[maybe_unused]] void** memDesc, [[maybe_unused]] uint32_t* memDescLen)
      63              : {
      64            0 :     HCCL_INFO("UbMemEndpoint MemoryExport is not supported");
      65            0 :     return HCCL_SUCCESS;
      66              : }
      67              : 
      68            0 : HcclResult UbMemEndpoint::MemoryImport(
      69              :     [[maybe_unused]] const void* memDesc, [[maybe_unused]] uint32_t descLen, [[maybe_unused]] HcommMem* outMem)
      70              : {
      71            0 :     HCCL_INFO("UbMemEndpoint MemoryImport is not supported");
      72            0 :     return HCCL_SUCCESS;
      73              : }
      74              : 
      75            0 : HcclResult UbMemEndpoint::MemoryUnimport([[maybe_unused]] const void* memDesc, [[maybe_unused]] uint32_t descLen)
      76              : {
      77            0 :     HCCL_INFO("UbMemEndpoint MemoryUnimport is not supported");
      78            0 :     return HCCL_SUCCESS;
      79              : }
      80              : 
      81            0 : HcclResult UbMemEndpoint::GetAllMemHandles([[maybe_unused]] void** memHandles, [[maybe_unused]] uint32_t* memHandleNum)
      82              : {
      83            0 :     HCCL_INFO("UbMemEndpoint GetAllMemHandles is not supported");
      84            0 :     return HCCL_SUCCESS;
      85              : }
      86              : } // namespace hcomm
        

Generated by: LCOV version 2.0-1