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