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

Generated by: LCOV version 2.0-1