Loading...
Searching...
No Matches
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#include <ucxx/memory_handle_builder.h>
15#include <ucxx/remote_key_builder.h>
16
17namespace ucxx {
18
19class RemoteKey;
20
28class MemoryHandle : public Component {
29 private:
30 ucp_mem_h _handle{};
31 size_t _size{0};
32 uint64_t _baseAddress{0};
33 ucs_memory_type_t _memoryType{
34 UCS_MEMORY_TYPE_HOST};
35
56 MemoryHandle(std::shared_ptr<Context> context,
57 const size_t size,
58 void* buffer,
59 const ucs_memory_type_t memoryType);
60
61 public:
62 MemoryHandle() = delete;
63 MemoryHandle(const MemoryHandle&) = delete;
64 MemoryHandle& operator=(MemoryHandle const&) = delete;
65 MemoryHandle(MemoryHandle&& o) = delete;
66 MemoryHandle& operator=(MemoryHandle&& o) = delete;
67
68 // Allow internal construction without exposing factory functions.
69 friend class detail::ConstructorFactory;
70
71 ~MemoryHandle();
72
88 [[nodiscard]] ucp_mem_h getHandle();
89
103 [[nodiscard]] size_t getSize() const;
104
119 [[nodiscard]] uint64_t getBaseAddress();
120
129 [[nodiscard]] ucs_memory_type_t getMemoryType();
130
140};
141
142} // namespace ucxx
A UCXX component class to prevent early destruction of parent object.
Definition component.h:21
uint64_t getBaseAddress()
Get the base address of the memory allocation.
RemoteKeyBuilder remoteKeyBuilder()
Create a builder for a remote key from this memory allocation.
ucp_mem_h getHandle()
Get the underlying ucp_mem_h handle.
size_t getSize() const
Get the size of the memory allocation.
ucs_memory_type_t getMemoryType()
Get the memory type of the allocation.
Builder class for constructing std::shared_ptr<ucxx::RemoteKey> objects.
Definition remote_key_builder.h:25
Component holding a UCP rkey (remote key).
Definition remote_key.h:39
Definition address.h:16