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_v2.h"
22 :
23 : namespace hcomm {
24 :
25 : class UbMemRegedMemMgr : public RegedMemMgr {
26 : public:
27 : using LocalIpcRmaBufferMgr
28 : = hcomm::RmaBufferMgr<hccl::BufferKey<uintptr_t, u64>, std::shared_ptr<Hccl::LocalIpcRmaBuffer>>;
29 :
30 : UbMemRegedMemMgr();
31 11 : ~UbMemRegedMemMgr() = default;
32 :
33 : HcclResult RegisterMemory(HcommMem mem, const char* memTag, void** memHandle) override;
34 : HcclResult UnregisterMemory(void* memHandle) override;
35 : HcclResult
36 : MemoryExport(const EndpointDesc endpointDesc, void* memHandle, void** memDesc, uint32_t* memDescLen) override;
37 : HcclResult MemoryImport(const void* memDesc, uint32_t descLen, HcommMem* outMem) override;
38 : HcclResult MemoryUnimport(const void* memDesc, uint32_t descLen) override;
39 : HcclResult GetAllMemHandles(void** memHandles, uint32_t* memHandleNum) override;
40 :
41 : private:
42 : std::unique_ptr<LocalIpcRmaBufferMgr> localIpcRmaBufferMgr_{};
43 : std::vector<RegedBufferEntry<Hccl::LocalIpcRmaBuffer>> allRegisteredBuffers_;
44 : };
45 : } // namespace hcomm
46 :
47 : #endif // UB_MEM_H
|