LCOV - code coverage report
Current view: top level - base_comm/resources/reged_mems - ub_mem.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 58.1 % 31 18
Test Date: 2026-07-28 12:11:00 Functions: 63.6 % 11 7

            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.h"
      11              : #include <algorithm>
      12              : #include "log.h"
      13              : 
      14              : namespace hcomm {
      15              : 
      16           14 : UbMemRegedMemMgr::UbMemRegedMemMgr()
      17              : {
      18           14 :     localIpcRmaBufferMgr_ = std::make_unique<LocalIpcRmaBufferMgr>();
      19           14 : }
      20              :     
      21           16 : HcclResult UbMemRegedMemMgr::RegisterMemory(HcommMem mem, const char *memTag, void **memHandle)
      22              : {
      23           16 :     HCCL_INFO("[%s] Begin", __func__);
      24           16 :     CHK_PTR_NULL(localIpcRmaBufferMgr_);
      25           32 :     return RegisterMemoryImpl(mem, memTag, memHandle,
      26           16 :         localIpcRmaBufferMgr_, allRegisteredBuffers_, "UbMemRegedMemMgr",
      27            0 :         [&](auto& bufPtr, auto& parent) {
      28            4 :             return std::make_shared<Hccl::LocalIpcRmaBuffer>(bufPtr, *parent);
      29              :         },
      30           16 :         [&](auto& bufPtr) {
      31            9 :             return std::make_shared<Hccl::LocalIpcRmaBuffer>(bufPtr);
      32           16 :         });
      33              : }
      34              : 
      35           16 : HcclResult UbMemRegedMemMgr::UnregisterMemory(void* memHandle)
      36              : {
      37           16 :     HCCL_INFO("[%s] Begin", __func__);
      38           16 :     CHK_PTR_NULL(localIpcRmaBufferMgr_);
      39           16 :     return UnregisterMemoryImpl(memHandle, localIpcRmaBufferMgr_, allRegisteredBuffers_,
      40           10 :         [](auto* b) { return b->GetIpcPtr(); },
      41           21 :         [](auto a, auto b) { return a == b; });
      42              : }
      43              : 
      44            0 : HcclResult UbMemRegedMemMgr::MemoryExport(const EndpointDesc endpointDesc, void *memHandle, void **memDesc, uint32_t *memDescLen)
      45              : {
      46            0 :     HCCL_INFO("UbMemRegedMemMgr MemoryExport is not supported.");
      47            0 :     return HCCL_SUCCESS;
      48              : }
      49              : 
      50            0 : HcclResult UbMemRegedMemMgr::MemoryImport(const void *memDesc, uint32_t descLen, HcommMem *outMem)
      51              : {
      52            0 :     HCCL_INFO("UbMemRegedMemMgr MemoryImport is not supported.");
      53            0 :     return HCCL_SUCCESS;
      54              : }
      55              : 
      56            0 : HcclResult UbMemRegedMemMgr::MemoryUnimport(const void *memDesc, uint32_t descLen)
      57              : {
      58            0 :     HCCL_INFO("UbMemRegedMemMgr MemoryUnimport is not supported.");
      59            0 :     return HCCL_SUCCESS;
      60              : }
      61              : 
      62            0 : HcclResult UbMemRegedMemMgr::GetAllMemHandles(void **memHandles, uint32_t *memHandleNum)
      63              : {
      64            0 :     HCCL_INFO("UbMemRegedMemMgr GetAllMemHandles is not supported.");
      65            0 :     return HCCL_SUCCESS;
      66              : }
      67              : }
        

Generated by: LCOV version 2.0-1