LCOV - code coverage report
Current view: top level - legacy/ascend910/platform/resource/rma_buffer - remote_rdma_rma_buffer.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 39 0
Test Date: 2026-07-28 12:11:00 Functions: 0.0 % 5 0

            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_rdma_rma_buffer.h"
      12              : #include "remote_rdma_rma_buffer_impl.h"
      13              : 
      14              : namespace hccl {
      15            0 : RemoteRdmaRmaBuffer::RemoteRdmaRmaBuffer()
      16            0 :     : RmaBuffer(nullptr, nullptr, 0, RmaMemType::TYPE_NUM, RmaType::RDMA_RMA)
      17              : {
      18            0 :     pimpl_ = std::make_unique<RemoteRdmaRmaBufferImpl>();
      19            0 : }
      20              : 
      21            0 : RemoteRdmaRmaBuffer::~RemoteRdmaRmaBuffer()
      22              : {
      23            0 :     if (pimpl_ != nullptr) {
      24            0 :         pimpl_  = nullptr;
      25            0 :         addr    = nullptr;
      26            0 :         size    = 0;
      27            0 :         devAddr = nullptr;
      28              :     }
      29            0 : }
      30              : 
      31            0 : HcclResult RemoteRdmaRmaBuffer::Deserialize(const std::string& msg)
      32              : {
      33            0 :     std::istringstream iss(msg);
      34            0 :     u8 type{static_cast<u8>(RmaType::RMA_TYPE_RESERVED)};  
      35            0 :     iss.read(reinterpret_cast<char_t *>(&type), sizeof(type));
      36            0 :     iss.read(reinterpret_cast<char_t *>(&addr), sizeof(addr));
      37            0 :     iss.read(reinterpret_cast<char_t *>(&size), sizeof(size));
      38            0 :     iss.read(reinterpret_cast<char_t *>(&devAddr), sizeof(devAddr));
      39            0 :     iss.read(reinterpret_cast<char_t *>(&memType), sizeof(memType));
      40            0 :     CHK_PTR_NULL(addr);
      41            0 :     CHK_PTR_NULL(devAddr);
      42            0 :     CHK_PRT_RET((memType >= RmaMemType::TYPE_NUM),
      43              :         HCCL_ERROR("[RemoteRdmaRmaBuffer][Deserialize]RmaMemType[%d] is invalid.", static_cast<int>(memType)),
      44              :         HCCL_E_PARA);
      45            0 :     CHK_PRT_RET(type >= static_cast<u8>(RmaType::RMA_TYPE_RESERVED), HCCL_ERROR("[RemoteRdmaRmaBuffer][Deserialize]rmaType[%d] is invalid.", type),
      46              :         HCCL_E_PARA);
      47            0 :     CHK_PRT_RET((size == 0 || (memType == RmaMemType::HOST && size >= HOST_MEM_MAX_COUNT) ||
      48              :         (memType == RmaMemType::DEVICE && size >= DEVICE_MEM_MAX_COUNT)),
      49              :         HCCL_ERROR(
      50              :             "[RemoteRdmaRmaBuffer][Deserialize]memory size[%llu] should be greater than 0 and less than [%llu].",
      51              :             size,
      52              :             (memType == RmaMemType::DEVICE ? DEVICE_MEM_MAX_COUNT : HOST_MEM_MAX_COUNT)), HCCL_E_PARA);
      53              : 
      54            0 :     HCCL_DEBUG("[RemoteRdmaRmaBuffer][Deserialize]addr[%p], size[%llu], devAddr[%p], memType[%d]",
      55              :         addr, size, devAddr, memType);
      56              : 
      57            0 :     CHK_SMART_PTR_NULL(pimpl_);
      58            0 :     if (rmaType != static_cast<RmaType>(type)) {
      59            0 :         HCCL_ERROR("[RemoteRdmaRmaBuffer][Deserialize]rmaType[%d] is not match to [%d].", type, rmaType);
      60            0 :         return HCCL_E_INTERNAL;
      61              :     }
      62              :     
      63            0 :     std::string remainingMsg = std::string((std::istreambuf_iterator<char>(iss)), std::istreambuf_iterator<char>());
      64            0 :     HcclResult ret = pimpl_->Deserialize(remainingMsg);
      65            0 :     if (ret != HCCL_SUCCESS) {
      66            0 :         pimpl_ = nullptr;
      67            0 :         HCCL_ERROR("[RemoteRdmaRmaBuffer]Deserialize failed, ret[%d]", ret);
      68            0 :         return ret;
      69              :     }
      70            0 :     return HCCL_SUCCESS;
      71            0 : }
      72              : 
      73            0 : u32 RemoteRdmaRmaBuffer::GetKey() const
      74              : {
      75            0 :     return pimpl_->GetKey();
      76              : }
      77              : }
        

Generated by: LCOV version 2.0-1