libucxx  0.37.00
All Classes Namespaces Functions Variables Typedefs Enumerations Friends
memory_handle.h
1 
5 #pragma once
6 #include <memory>
7 #include <string>
8 #include <utility>
9 
10 #include <ucp/api/ucp.h>
11 
12 #include <ucxx/component.h>
13 #include <ucxx/context.h>
14 
15 namespace ucxx {
16 
17 class RemoteKey;
18 
26 class MemoryHandle : public Component {
27  private:
28  ucp_mem_h _handle{};
29  size_t _size{0};
30  uint64_t _baseAddress{0};
31 
51  MemoryHandle(std::shared_ptr<Context> context, const size_t size, void* buffer);
52 
53  public:
54  MemoryHandle() = delete;
55  MemoryHandle(const MemoryHandle&) = delete;
56  MemoryHandle& operator=(MemoryHandle const&) = delete;
57  MemoryHandle(MemoryHandle&& o) = delete;
58  MemoryHandle& operator=(MemoryHandle&& o) = delete;
59 
105  friend std::shared_ptr<MemoryHandle> createMemoryHandle(std::shared_ptr<Context> context,
106  const size_t size,
107  void* buffer);
108 
109  ~MemoryHandle();
110 
126  ucp_mem_h getHandle();
127 
141  size_t getSize() const;
142 
157  uint64_t getBaseAddress();
158 
159  std::shared_ptr<RemoteKey> createRemoteKey();
160 };
161 
162 } // namespace ucxx
A UCXX component class to prevent early destruction of parent object.
Definition: component.h:17
Component holding a UCP memory handle.
Definition: memory_handle.h:26
friend std::shared_ptr< MemoryHandle > createMemoryHandle(std::shared_ptr< Context > context, const size_t size, void *buffer)
Constructor for shared_ptr<ucxx::MemoryHandle>.
uint64_t getBaseAddress()
Get the base address of the memory allocation.
ucp_mem_h getHandle()
Get the underlying ucp_mem_h handle.
size_t getSize() const
Get the size of the memory allocation.
Definition: address.h:15