LCOV - code coverage report
Current view: top level - base_comm/resources/endpoint_pairs/channels/aiv - aiv_ub_mem_transport.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 2 2
Test Date: 2026-08-18 17:47:01 Functions: 57.1 % 7 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              : #ifndef AIV_UB_MEM_TRANSPORT_H
      12              : #define AIV_UB_MEM_TRANSPORT_H
      13              : #include <mutex>
      14              : #include "hccl/hccl_res.h"
      15              : #include "../../../../../../legacy/ascend950/unified_platform/resource/socket/socket.h"
      16              : #include "../../../../../../legacy/ascend950/unified_platform/resource/buffer/local_ipc_rma_buffer_v2.h"
      17              : #include "../../../../../../legacy/ascend950/unified_platform/resource/buffer/remote_rma_buffer.h"
      18              : #include "binary_stream.h"
      19              : #include "buffer.h"
      20              : #include "transport_status.h"
      21              : 
      22              : namespace hcomm {
      23              : class AivUbMemTransport {
      24              : public:
      25           34 :     MAKE_ENUM(
      26              :         AivUbMemTransportStatus, INIT, SOCKET_OK, SEND_DATA_SIZE, RECV_DATA_SIZE, SEND_MEM_INFO, RECV_MEM_INFO,
      27              :         RECV_MEM_FIN, CONNECT_FAILED, SOCKET_TIMEOUT, READY);
      28              :     AivUbMemTransport(Hccl::Socket* socket, HcommChannelDesc& channelDesc);
      29           10 :     ~AivUbMemTransport() = default;
      30              :     HcclResult
      31              :     FillBufferVec(HcommMemHandle* memHandles, uint32_t bufferNum, std::vector<Hccl::LocalIpcRmaBuffer*>& bufferVec);
      32              :     HcclResult Init();
      33              :     Hccl::TransportStatus GetStatus();
      34              :     HcclResult GetRemoteMems(uint32_t* memNum, CommMem** remoteMem, char*** memInfos);
      35              :     HcclResult CheckSocketStatus(std::string socketOperator);
      36              :     HcclResult UpdateMemInfo(HcommMemHandle* memHandles, uint32_t memHandleNum);
      37              : 
      38              : private:
      39              :     Hccl::Socket* socket_{}; // 交换所用的socket
      40              :     HcommChannelDesc channelDesc_;
      41              :     uint32_t exchangeDataSize_{0};
      42              :     std::vector<CommMem> remoteUserMems_;    // 储存内存位置、地址和大小信息
      43              :     std::vector<std::string> memInfoCopies_; // 储存memInfo字符串副本
      44              :     std::vector<char*> memInfoPointers_;     // 储存指针
      45              :     bool cacheValid_ = false;                // 当前缓存是否有效
      46              : 
      47              :     std::vector<Hccl::LocalIpcRmaBuffer*> localRmaBufferVec_{};
      48              :     std::vector<Hccl::LocalIpcRmaBuffer*> locMemTemp_{};
      49              :     std::vector<std::unique_ptr<Hccl::RemoteIpcRmaBuffer>> rmtBufferVec_{};
      50              :     std::vector<Hccl::RemoteRmaBuffer*> rmtRmaBufferVec_{};
      51              :     AivUbMemTransportStatus aivUbStatus_{AivUbMemTransportStatus::INVALID};
      52              :     Hccl::TransportStatus baseStatus_{Hccl::TransportStatus::INVALID};
      53              :     std::mutex remoteMemsMutex_; // 远端内存列表互斥锁
      54              : 
      55              :     std::vector<char> sendData_{};
      56              :     std::vector<char> recvData_{};
      57              : 
      58              :     HcclResult IsSocketReady(bool& isReady);
      59              :     HcclResult SendDataSize();
      60              :     HcclResult RecvDataSize();
      61              :     HcclResult SendMemInfo();
      62              :     HcclResult RecvMemInfo();
      63              :     HcclResult RecvDataProcess();
      64              :     HcclResult BufferPack(Hccl::BinaryStream& binaryStream, std::vector<Hccl::LocalIpcRmaBuffer*>& bufferVec);
      65              :     void RmtBufferUnpackProc(Hccl::BinaryStream& binaryStream);
      66              :     HcclResult StateMachine();
      67              :     Hccl::TransportStatus UpdateStatus();
      68              :     void CheckStatusFuncResult(std::string funcName, HcclResult ret);
      69              : };
      70              : 
      71              : } // namespace hcomm
      72              : 
      73              : #endif // AIV_UB_MEM_TRANSPORT_H
        

Generated by: LCOV version 2.0-1