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  ucs_memory_type_t _memoryType{
32  UCS_MEMORY_TYPE_HOST};
33 
54  MemoryHandle(std::shared_ptr<Context> context,
55  const size_t size,
56  void* buffer,
57  const ucs_memory_type_t memoryType);
58 
59  public:
60  MemoryHandle() = delete;
61  MemoryHandle(const MemoryHandle&) = delete;
62  MemoryHandle& operator=(MemoryHandle const&) = delete;
63  MemoryHandle(MemoryHandle&& o) = delete;
64  MemoryHandle& operator=(MemoryHandle&& o) = delete;
65 
112  [[nodiscard]] friend std::shared_ptr<MemoryHandle> createMemoryHandle(
113  std::shared_ptr<Context> context,
114  const size_t size,
115  void* buffer,
116  const ucs_memory_type_t memoryType);
117 
118  ~MemoryHandle();
119 
135  [[nodiscard]] ucp_mem_h getHandle();
136 
150  [[nodiscard]] size_t getSize() const;
151 
166  [[nodiscard]] uint64_t getBaseAddress();
167 
168  [[nodiscard]] ucs_memory_type_t getMemoryType();
169 
170  [[nodiscard]] std::shared_ptr<RemoteKey> createRemoteKey();
171 };
172 
173 } // 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, const ucs_memory_type_t memoryType)
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