This module is responsible for allocating and managing memory on the device.
More...
#include <vart_memory.hpp>
This module is responsible for allocating and managing memory on the device.
- See also
- MemoryImplBase
◆ Memory() [1/4]
| vart::Memory::Memory |
( |
MemoryImplType |
type, |
|
|
size_t |
size, |
|
|
uint8_t |
mbank_idx, |
|
|
std::shared_ptr< Device > |
device |
|
) |
| |
Memory() - Constructor to allocate memory using implementation specific method based on input 'type'.
- Parameters
-
| [in] | type | Enum class to specify which type of memory allocation method to use |
| [in] | size | Size of the buffer |
| [in] | mbank_idx | memory bank index on which memory needs to be allocated |
| [in] | device | Device handle. Must be non-null. See vart::Device for more details. |
◆ Memory() [2/4]
| vart::Memory::Memory |
( |
MemoryImplType |
type, |
|
|
uint8_t * |
data, |
|
|
size_t |
size, |
|
|
std::shared_ptr< Device > |
device |
|
) |
| |
Memory() - Constructor to create Memory instance using user provided data pointer.
- Parameters
-
| [in] | type | Enum class to specify which type of memory allocation method to use |
| [in] | data | User-allocated buffer pointer. Ownership remains with the caller; the caller must keep the buffer valid for the lifetime of this Memory. |
| [in] | size | Size of the buffer in bytes (must match the allocation pointed to by data). |
| [in] | device | Device handle. Must be non-null. See vart::Device for more details. |
◆ Memory() [3/4]
Memory() - Constructor for using user defined implementation.
- Parameters
-
| [in] | ptr | Pointer to user's implementation instance. Must be non-null; the constructor stores it as the pimpl and subsequent method calls dereference it without an additional null check. |
◆ Memory() [4/4]
| vart::Memory::Memory |
( |
MemoryImplType |
type, |
|
|
int |
dma_fd, |
|
|
size_t |
size, |
|
|
std::shared_ptr< Device > |
device |
|
) |
| |
Memory() - Constructor to create Memory instance from a dma-buf file descriptor.
- Parameters
-
| [in] | type | Enum class to specify which type of memory allocation method to use. type must be MemoryImplType::XRT. Any other type throws std::runtime_error. |
| [in] | dma_fd | DMA-BUF file descriptor to import. The file descriptor represents a CMA-backed buffer exported from another component. |
| [in] | size | Size of the buffer (must match the actual buffer size) |
| [in] | device | Device handle. Must be non-null. See vart::Device for more details. |
- Exceptions
-
| std::runtime_error | If type is not MemoryImplType::XRT, the file descriptor is invalid, the buffer is not CMA-backed, or the import operation fails. |
◆ ~Memory()
| vart::Memory::~Memory |
( |
| ) |
|
|
default |
◆ export_buffer()
| int vart::Memory::export_buffer |
( |
| ) |
const |
export_buffer() - Export the underlying buffer as a dma-buf file descriptor
- Returns
- Returns a file descriptor (int) representing the dma-buf on success (>= 0). Returns -1 on failure (buffer not CMA-backed, invalid state, or export error).
◆ get_device_handle()
| std::shared_ptr<Device> vart::Memory::get_device_handle |
( |
| ) |
const |
◆ get_physical_addr()
| uint64_t vart::Memory::get_physical_addr |
( |
| ) |
|
get_physical_addr() - Retrieves the physical address of the allocated memory.
- Returns
- Physical (device) address of the underlying buffer for
XRT-backed allocations.
- Exceptions
-
◆ get_pimpl_handle()
| const std::shared_ptr<MemoryImplBase>& vart::Memory::get_pimpl_handle |
( |
| ) |
const |
get_pimpl_handle() - Retrieves pointer to Memory Implementation Base class
- Returns
- Returns a constant reference of pointer to implementation class.
◆ get_size()
| size_t vart::Memory::get_size |
( |
| ) |
|
get_size() - gets the size of the allocated memory
- Returns
- returns the memory size
◆ map()
map() - Maps allocated memory to user space.
- Parameters
-
| [in] | map_flags | Flag used to indicate mode of memory mapping. May combine bits from DataMapFlags (e.g. READ|WRITE). |
- Returns
- Virtual address of the mapped buffer on success, or
nullptr on failure.
- Note
- Both
XRT and NON_CMA memory types support map().
◆ unmap()
| void vart::Memory::unmap |
( |
| ) |
|
unmap() - Unmaps allocated memory from user space.
- Exceptions
-
| std::runtime_error | If called without a prior successful map(). |
The documentation for this class was generated from the following file: