LCOV - code coverage report
Current view: top level - legacy/ascend910/platform/resource/transport/onesided/device - transport_device_roce_mem.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 4 0
Test Date: 2026-07-28 12:11:00 Functions: 0.0 % 1 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              : #ifndef TRANSPORT_DEVICE_ROCE_MEM_H
      12              : #define TRANSPORT_DEVICE_ROCE_MEM_H
      13              : 
      14              : #include "transport_mem.h"
      15              : #include <atomic>
      16              : #include <chrono>
      17              : 
      18              : namespace hccl {
      19              : class TransportDeviceRoceMem : public TransportMem {
      20              : public:
      21              :     TransportDeviceRoceMem(const std::unique_ptr<NotifyPool> &notifyPool, const HcclNetDevCtx &netDevCtx,
      22              :         const HcclDispatcher &dispatcher, AttrInfo &attrInfo, bool aicpuUnfoldMode, const HcclQpInfoV2 &qpInfo);
      23              :     ~TransportDeviceRoceMem() override;
      24              : 
      25              :     HcclResult ExchangeMemDesc(const RmaMemDescs &localMemDescs, RmaMemDescs &remoteMemDescs,
      26              :         u32 &actualNumOfRemote) override;
      27              :     HcclResult EnableMemAccess(const RmaMemDesc &remoteMemDesc, RmaMem &remoteMem) override;
      28              :     HcclResult DisableMemAccess(const RmaMemDesc &remoteMemDesc) override;
      29              :     HcclResult SetSocket(const std::shared_ptr<HcclSocket> &socket) override;
      30              :     HcclResult Connect(s32 timeoutSec) override;
      31              :     HcclResult Write(const HcclBuf &remoteMem, const HcclBuf &localMem, const rtStream_t &stream) override;
      32              :     HcclResult Read(const HcclBuf &localMem, const HcclBuf &remoteMem, const rtStream_t &stream) override;
      33              :     HcclResult Write(const RmaOpMem &remoteMem, const RmaOpMem &localMem, const rtStream_t &stream) override;
      34              :     HcclResult Read(const RmaOpMem &localMem, const RmaOpMem &remoteMem, const rtStream_t &stream) override;
      35              :     HcclResult AddOpFence(const rtStream_t &stream) override;
      36              :     HcclResult GetTransInfo(HcclQpInfoV2 &qpInfo, u32 *lkey, u32 *rkey, HcclBuf *localMem, HcclBuf *remoteMem,
      37              :         u32 num) override;
      38              :     HcclResult WaitOpFence(const rtStream_t &stream) override;
      39              : 
      40              :     HcclResult BatchWrite(const std::vector<MemDetails> &remoteMems, const std::vector<MemDetails> &localMems,
      41              :         Stream &stream) override;
      42              :     HcclResult BatchRead(const std::vector<MemDetails> &localMems, const std::vector<MemDetails> &remoteMems,
      43              :         Stream &stream) override;
      44              :     HcclResult AddOpFence(const MemDetails &localFenceMem, const MemDetails &remoteFenceMem, Stream &stream) override;
      45              : 
      46              : private:
      47              :     enum class RdmaOp {
      48              :         OP_WRITE = 0,
      49              :         OP_READ = 4
      50              :     };
      51              : 
      52              :     template<typename T>
      53            0 :     inline T CeilDiv(T left, T right)
      54              :     {
      55            0 :         if (right == 0) {
      56            0 :             return left;
      57              :         }
      58            0 :         return (left + right - 1) / right;
      59              :     }
      60              : 
      61              :     HcclResult BatchOp(Stream &stream, const std::vector<MemDetails> &localMems,
      62              :         const std::vector<MemDetails> &remoteMems, bool isRead, bool fence);
      63              :     HcclResult FillMemDetails(std::vector<MemDetails> &localMemList, std::vector<MemDetails> &remoteMemList,
      64              :         MemDetails &localMem, MemDetails &remoteMem);
      65              :     HcclResult DoorBellSend(Stream &stream, u64 dbInfo, u32 wrDataLen, bool fence);
      66              :     HcclResult BatchPostSend(Stream &stream, u64 &dbInfo, std::vector<MemDetails> &localMemList,
      67              :         std::vector<MemDetails> &remoteMemList, bool isRead, bool fence, u32 &wqeCount, u64 &wrDataLen);
      68              :     HcclResult PostSend(Stream &stream, u64 &dbInfo, MemDetails *localMems, MemDetails *remoteMems, u32 memNum,
      69              :         bool isRead, bool fence, u32 &wqeCount, u64 &wrDataLen);
      70              :     HcclResult RdmaPostSend(u64 &dbInfo, MemDetails *localMems, MemDetails *remoteMems, u32 memNum, RdmaOp opCode,
      71              :         bool fence);
      72              : 
      73              :     static std::atomic<u64> wrIdOffset_;
      74              : 
      75              :     const u64 MAX_RDMA_WQE_SIZE = 2ULL * 1024 * 1024 * 1024; // RDMA最大WQE限制, 2G限制是RDMA导致
      76              :     const u32 SEND_WR_LEN = 64;
      77              :     const std::chrono::microseconds timeout_;
      78              :     HcclQpInfoV2 qpInfo_{};
      79              : };
      80              : }  // namespace hccl
      81              : #endif
        

Generated by: LCOV version 2.0-1