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 : #ifndef UB_MEM_H
11 : #define UB_MEM_H
12 :
13 : #include <memory>
14 : #include <vector>
15 : #include <string>
16 : #include "reged_mem_mgr.h"
17 : #include "rma_buffer_mgr.h"
18 : #include "buffer_key.h"
19 : #include "local_ub_rma_buffer.h"
20 : #include "remote_rma_buffer.h"
21 : #include "../../../../../../legacy/ascend950/unified_platform/resource/buffer/local_ipc_rma_buffer.h"
22 :
23 : namespace hcomm {
24 :
25 : class UbMemRegedMemMgr : public RegedMemMgr {
26 : public:
27 : using LocalIpcRmaBufferMgr = hccl::RmaBufferMgr<hccl::BufferKey<uintptr_t, u64>, std::shared_ptr<Hccl::LocalIpcRmaBuffer>>;
28 :
29 : UbMemRegedMemMgr();
30 7 : ~UbMemRegedMemMgr() = default;
31 :
32 : HcclResult RegisterMemory(HcommMem mem, const char *memTag, void **memHandle) override;
33 : HcclResult UnregisterMemory(void* memHandle) override;
34 : HcclResult MemoryExport(const EndpointDesc endpointDesc, void *memHandle, void **memDesc, uint32_t *memDescLen) override;
35 : HcclResult MemoryImport(const void *memDesc, uint32_t descLen, HcommMem *outMem) override;
36 : HcclResult MemoryUnimport(const void *memDesc, uint32_t descLen) override;
37 : HcclResult GetAllMemHandles(void **memHandles, uint32_t *memHandleNum) override;
38 :
39 : private:
40 : std::unique_ptr<LocalIpcRmaBufferMgr> localIpcRmaBufferMgr_{};
41 : std::vector<RegedBufferEntry<Hccl::LocalIpcRmaBuffer>> allRegisteredBuffers_;
42 : };
43 : }
44 :
45 : #endif // UB_MEM_H
|