LCOV - code coverage report
Current view: top level - base_comm/resources/reged_mems - aicpu_ts_roce_mem.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 33.3 % 3 1
Test Date: 2026-08-17 10:19:35 Functions: 33.3 % 3 1

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2026 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              : #ifndef AICPU_TS_ROCE_MEM_H
      11              : #define AICPU_TS_ROCE_MEM_H
      12              : 
      13              : #include <cstring>
      14              : #include <map>
      15              : #include <memory>
      16              : #include <string>
      17              : #include <unordered_map>
      18              : #include <vector>
      19              : #include "reged_mem_mgr.h"
      20              : #include "hccl_mem_defs.h"
      21              : #include "hccl_network.h"
      22              : #include "transport_pub.h"
      23              : #include "local_rdma_rma_buffer.h"
      24              : #include "remote_rdma_rma_buffer.h"
      25              : 
      26              : namespace hcomm {
      27              : class AicpuTsRoceRegedMemMgr : public RegedMemMgr {
      28              : public:
      29              :     AicpuTsRoceRegedMemMgr(HcclNetDev netDev, RdmaHandle rdmaHandle);
      30           25 :     ~AicpuTsRoceRegedMemMgr() override = default;
      31              : 
      32              :     HcclResult RegisterMemory(HcommMem mem, const char* memTag, void** memHandle) override;
      33              :     HcclResult UnregisterMemory(void* memHandle) override;
      34              :     HcclResult
      35              :     MemoryExport(const EndpointDesc endpointDesc, void* memHandle, void** memDesc, uint32_t* memDescLen) override;
      36              :     HcclResult MemoryImport(const void* memDesc, uint32_t descLen, HcommMem* outMem) override;
      37              :     HcclResult MemoryUnimport(const void* memDesc, uint32_t descLen) override;
      38              :     HcclResult GetAllMemHandles(void** memHandles, uint32_t* memHandleNum) override;
      39              : 
      40              :     HcclResult GetAllMemDetails(std::vector<RoceMemDetails>& localOut, std::vector<RoceMemDetails>& remoteOut) const;
      41              : 
      42              : private:
      43              :     using RemoteRdmaRmaBufferMgr
      44              :         = hcomm::RmaBufferMgr<hccl::BufferKey<uintptr_t, u64>, std::shared_ptr<hccl::RemoteRdmaRmaBuffer>>;
      45              : 
      46              :     struct EndpointDescLess {
      47            0 :         bool operator()(const EndpointDesc& a, const EndpointDesc& b) const noexcept
      48              :         {
      49            0 :             return std::memcmp(&a, &b, sizeof(EndpointDesc)) < 0;
      50              :         }
      51              :     };
      52              : 
      53              :     HcclResult
      54              :     GetParamsFromMemDesc(const void* memDesc, uint32_t descLen, EndpointDesc& endpointDesc, std::string& rdmaBlob);
      55              :     void TrackRegisteredBuffer(const std::shared_ptr<hccl::LocalRdmaRmaBuffer>& localBuffer);
      56              : 
      57              :     HcclResult GatherLocalMemDetails(std::vector<RoceMemDetails>& localOut) const;
      58              :     HcclResult AppendLocalNotifyMemDetails(std::vector<RoceMemDetails>& localOut) const;
      59              :     void GatherRemoteMemDetails(std::vector<RoceMemDetails>& remoteOut) const;
      60              : 
      61              :     HcclNetDev netDev_{nullptr};
      62              :     std::shared_ptr<hccl::NetDevContext::LocalRdmaRmaBufferMgr> localRdmaRmaBufferMgr_{nullptr};
      63              :     std::vector<RegedBufferEntry<hccl::LocalRdmaRmaBuffer>> allRegisteredBuffers_;
      64              :     std::vector<HcclBuf> hcclBufRecords_;
      65              :     std::unordered_map<hccl::LocalRdmaRmaBuffer*, std::vector<char>> exportDescByBuffer_;
      66              :     std::map<EndpointDesc, std::unique_ptr<RemoteRdmaRmaBufferMgr>, EndpointDescLess> remoteRdmaRmaBufferMgrs_;
      67              : };
      68              : 
      69              : } // namespace hcomm
      70              : #endif // AICPU_TS_ROCE_MEM_H
        

Generated by: LCOV version 2.0-1