LCOV - code coverage report
Current view: top level - legacy/ascend950/unified_platform/resource/transport - p2p_transport.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 2 2
Test Date: 2026-08-18 17:47:01 Functions: 50.0 % 6 3

            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 P2P_TRANSPORT_H
      12              : #define P2P_TRANSPORT_H
      13              : 
      14              : #include "base_mem_transport.h"
      15              : #include "virtual_topo.h"
      16              : #include "ipc_remote_notify.h"
      17              : #include "../../../resource/buffer/local_ipc_rma_buffer_v2.h"
      18              : #include "remote_rma_buffer.h"
      19              : 
      20              : namespace Hccl {
      21              : class P2PTransport : public BaseMemTransport {
      22              : public:
      23              :     P2PTransport(CommonLocRes& commonLocRes, Attribution& attr, const LinkData& linkData, const Socket& socket);
      24              : 
      25              :     P2PTransport(
      26              :         CommonLocRes& commonLocRes, Attribution& attr, const LinkData& linkData, const Socket& socket,
      27              :         std::function<void(u32 streamId, u32 taskId, TaskParam taskParam)> callback);
      28              : 
      29           29 :     ~P2PTransport() override = default;
      30              : 
      31              :     std::string Describe() const override;
      32              : 
      33              :     TransportStatus GetStatus() override;
      34              : 
      35              :     std::vector<char> GetUniqueId() override;
      36              : 
      37              :     std::vector<char> GetUniqueIdV2();
      38              : 
      39              :     void Post(u32 index, const Stream& stream) override;
      40              : 
      41              :     void Read(const RmaBufferSlice& locSlice, const RmtRmaBufferSlice& rmtSlice, const Stream& stream) override;
      42              : 
      43              :     void ReadReduce(
      44              :         const RmaBufferSlice& locSlice, const RmtRmaBufferSlice& rmtSlice, const ReduceIn& reduceIn,
      45              :         const Stream& stream) override;
      46              : 
      47              :     void Write(const RmaBufferSlice& locSlice, const RmtRmaBufferSlice& rmtSlice, const Stream& stream) override;
      48              : 
      49              :     void WriteReduce(
      50              :         const RmaBufferSlice& locSlice, const RmtRmaBufferSlice& rmtSlice, const ReduceIn& reduceIn,
      51              :         const Stream& stream) override;
      52              : 
      53              :     HcclResult GetRemoteMems(uint32_t* memNum, CommMem** remoteMem, char*** memInfos);
      54              : 
      55              : private:
      56              :     MemoryBuffer GetLocMemBuffer(const RmaBufferSlice& locSlice) const;
      57              :     MemoryBuffer GetRmtMemBuffer(const RmtRmaBufferSlice& rmtSlice) const;
      58              : 
      59           19 :     MAKE_ENUM(
      60              :         P2PStatus, INIT, SOCKET_OK, SEND_PID, RECV_PID, GRANT, SEND_DATA, RECV_DATA, SEND_DATA_SIZE, RECV_DATA_SIZE)
      61              :     P2PStatus p2pStatus{P2PStatus::INIT};
      62              : 
      63              :     u32 pidMsgSize{0};
      64              :     u32 myPid{0};
      65              :     u32 rmtPid{0};
      66              : 
      67              :     bool rmtPidValid{false};
      68              : 
      69              :     std::vector<std::unique_ptr<IpcRemoteNotify>> rmtNotifyVec;
      70              :     std::vector<std::unique_ptr<RemoteIpcRmaBuffer>> rmtBufferVec;
      71              : 
      72              :     bool cacheValid_ = false;                // 当前缓存是否有效
      73              :     std::vector<CommMem> remoteUserMems_;    // 内存基本信息缓存
      74              :     std::vector<std::string> memInfoCopies_; // 储存 Tag 字符串副本
      75              :     std::vector<char*> memInfoPointers_;     // Tag 缓存
      76              :     std::vector<char> sendData;
      77              :     std::vector<char> recvData;
      78              : 
      79              :     bool IsRmtPidValid() const;
      80              :     void SendPid();
      81              :     void RecvPid();
      82              :     void Grant();
      83              :     void PrepareSendData();
      84              :     void RecvDataSize();
      85              :     void SendExchangeData();
      86              :     void RecvExchangeData();
      87              :     void ProcessRecvData();
      88              : 
      89              :     void BufferVecPack(BinaryStream& binaryStream);
      90              : 
      91              :     void RmtNotifyVecUnpackProc(BinaryStream& binaryStream);
      92              :     void RmtBufferVecUnpackProc(BinaryStream& binaryStream);
      93              : 
      94              :     std::vector<char> GetSingleRmtNotifyUniqueId(u64 addr, u64 size, u32 notifyId) const;
      95              :     std::vector<char> GetSingleBufferUniqueId(u64 addr, u64 size) const;
      96              :     std::vector<char> GetNotifyUniqueIds();
      97              :     std::vector<char> GetRmtNotifyUniqueIds() const;
      98              :     std::vector<char> GetLocBufferUniqueIds() const;
      99              :     std::vector<char> GetRmtBufferUniqueIds() const;
     100              : 
     101              :     std::mutex remoteMemsMutex_; // 远端内存列表互斥锁
     102              : };
     103              : 
     104              : } // namespace Hccl
     105              : 
     106              : #endif
        

Generated by: LCOV version 2.0-1