Loading...
Searching...
No Matches
ucxx::MemoryHandle Class Reference

Component holding a UCP memory handle. More...

#include <memory_handle.h>

Inheritance diagram for ucxx::MemoryHandle:
ucxx::Component

Public Member Functions

 MemoryHandle (const MemoryHandle &)=delete
MemoryHandle & operator= (MemoryHandle const &)=delete
 MemoryHandle (MemoryHandle &&o)=delete
MemoryHandle & operator= (MemoryHandle &&o)=delete
ucp_mem_h getHandle ()
 Get the underlying ucp_mem_h handle.
size_t getSize () const
 Get the size of the memory allocation.
uint64_t getBaseAddress ()
 Get the base address of the memory allocation.
ucs_memory_type_t getMemoryType ()
 Get the memory type of the allocation.
RemoteKeyBuilder remoteKeyBuilder ()
 Create a builder for a remote key from this memory allocation.
Public Member Functions inherited from ucxx::Component
void setParent (std::shared_ptr< Component > parent)
 Set the internal parent reference.
std::shared_ptr< Component > getParent () const
 Get the internal parent reference.

Friends

class detail::ConstructorFactory

Additional Inherited Members

Protected Attributes inherited from ucxx::Component
std::shared_ptr< Component > _parent {nullptr}
 A reference-counted pointer to the parent.

Detailed Description

Component holding a UCP memory handle.

The UCP layer provides RMA (Remote Memory Access) to memory handles that it controls in form of ucp_mem_h object, this class encapsulates that object and provides methods to simplify its handling.

Member Function Documentation

◆ getBaseAddress()

uint64_t ucxx::MemoryHandle::getBaseAddress ( )
nodiscard

Get the base address of the memory allocation.

Get the base address of the memory allocation, which is going to be used as the remote address to put or get memory via the ucxx::Endpoint::memPutBuilder() or ucxx::Endpoint::memGetBuilder() methods.

// memoryHandle is `std::shared_ptr<ucxx::MemoryHandle>`
auto memoryBase Address = memoryHandle->getBaseAddress();
Component encapsulating the address of a UCP worker.
Definition address.h:26
Returns
The base address of the memory allocation.

◆ getHandle()

ucp_mem_h ucxx::MemoryHandle::getHandle ( )
nodiscard

Get the underlying ucp_mem_h handle.

Lifetime of the ucp_mem_h handle is managed by the ucxx::MemoryHandle object and its ownership is non-transferrable. Once the ucxx::MemoryHandle is destroyed the memory is unmapped and the handle is not valid anymore, it is the user's responsibility to ensure the owner's lifetime while using the handle.

// memoryHandle is `std::shared_ptr<ucxx::MemoryHandle>`
ucp_mem_h ucpMemoryHandle = memoryHandle->getHandle();
Returns
The underlying ucp_mem_h handle.

◆ getMemoryType()

ucs_memory_type_t ucxx::MemoryHandle::getMemoryType ( )
nodiscard

Get the memory type of the allocation.

Get the memory type of the allocation, which indicates whether the memory is host memory or device memory (i.e., CUDA).

Returns
The memory type of the allocation.

◆ getSize()

size_t ucxx::MemoryHandle::getSize ( ) const
nodiscard

Get the size of the memory allocation.

Get the size of the memory allocation, which is at least the number of bytes specified with the size argument passed to memoryHandleBuilder().

// memoryHandle is `std::shared_ptr<ucxx::MemoryHandle>`
auto memorySize = memoryHandle->getSize();
Returns
The size of the memory allocation.

◆ remoteKeyBuilder()

RemoteKeyBuilder ucxx::MemoryHandle::remoteKeyBuilder ( )
nodiscard

Create a builder for a remote key from this memory allocation.

Calling this method only creates the builder. Finalizing it with .build() or implicit conversion creates a remote key that can be used by a remote endpoint.

Returns
Builder to create the remote key.

The documentation for this class was generated from the following file: