LCOV - code coverage report
Current view: top level - legacy/ascend950/framework/resource_manager/buffer - remote_rma_buf_manager.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 93.8 % 32 30
Test Date: 2026-08-17 10:19:35 Functions: 100.0 % 4 4

            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 "remote_rma_buf_manager.h"
      11              : #include "communicator_impl.h"
      12              : #include "rdma_handle_manager.h"
      13              : #include "internal_exception.h"
      14              : namespace Hccl {
      15              : 
      16          108 : RemoteRmaBufManager::RemoteRmaBufManager(const CommunicatorImpl& communicator)
      17          108 :     : comm(const_cast<CommunicatorImpl*>(&communicator))
      18          108 : {}
      19              : 
      20              : RemoteRmaBuffer*
      21            1 : RemoteRmaBufManager::GetRemoteRmaBuffer(const string& opTag, const LinkData& linkData, BufferType bufType)
      22              : {
      23            1 :     auto tagIter = remoteBufMap.find(opTag);
      24            1 :     if (tagIter != remoteBufMap.end()) {
      25            1 :         auto linkDataIter = tagIter->second.find(linkData);
      26            1 :         if (linkDataIter != tagIter->second.end()) {
      27            1 :             auto bufTypeIter = linkDataIter->second.find(bufType);
      28            1 :             if (bufTypeIter != linkDataIter->second.end()) {
      29            1 :                 return bufTypeIter->second.get();
      30              :             }
      31              :         }
      32              :     }
      33            0 :     HCCL_WARNING(
      34              :         "WARNING: RemoteRmaBuffer does not exist, "
      35              :         "errNo[0x%016llx], opTag[%s], linkData[%s], bufType[%s]",
      36              :         HCCL_ERROR_CODE(HcclResult::HCCL_E_PTR), opTag.c_str(), linkData.Describe().c_str(),
      37              :         bufType.Describe().c_str());
      38              : 
      39            0 :     return nullptr;
      40              : }
      41              : 
      42            4 : unique_ptr<RemoteRmaBuffer> RemoteRmaBufManager::Create(const LinkData& linkData) const
      43              : {
      44            4 :     if (linkData.GetType() == PortDeploymentType::P2P) {
      45            3 :         HCCL_INFO("Create remote Ipc RMA buffer.");
      46            1 :         return make_unique<RemoteIpcRmaBuffer>();
      47              :     } else {
      48            3 :         auto linkProtocol = linkData.GetLinkProtocol();
      49            3 :         if (linkProtocol == LinkProtocol::ROCE) {
      50            2 :             RdmaHandle rdmaHandle = RdmaHandleManager::GetInstance().Get(
      51            1 :                 comm->GetDevicePhyId(), linkData.GetLocalPort(), linkData.GetLinkProtocol());
      52            1 :             return make_unique<RemoteRdmaRmaBuffer>(rdmaHandle);
      53            2 :         } else if (linkProtocol == LinkProtocol::UB_CTP || linkProtocol == LinkProtocol::UB_TP) {
      54            2 :             RdmaHandle rdmaHandle = RdmaHandleManager::GetInstance().Get(
      55            1 :                 comm->GetDevicePhyId(), linkData.GetLocalPort(), linkData.GetLinkProtocol());
      56            1 :             return make_unique<RemoteUbRmaBuffer>(rdmaHandle);
      57              :         }
      58            1 :         string msg = StringFormat("LinkData[%s] is error", linkData.Describe().c_str());
      59            1 :         THROW<InternalException>(msg);
      60              :         return nullptr;
      61            1 :     }
      62              : }
      63              : 
      64            1 : void RemoteRmaBufManager::Bind(
      65              :     unique_ptr<RemoteRmaBuffer> remoteRmaBuf, const string& opTag, const LinkData& linkData, BufferType bufType)
      66              : {
      67            1 :     remoteBufMap[opTag][linkData][bufType] = std::move(remoteRmaBuf);
      68            1 : }
      69              : 
      70              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1