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

Generated by: LCOV version 2.0-1