Class vart::Memory#

class Memory

This module is responsible for allocating and managing memory on the device.

Public Functions

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:
  • type – Enum class to specify which type of memory allocation method to use

  • size – Size of the buffer

  • mbank_idx – memory bank index on which memory needs to be allocated

  • deviceDevice handle to be used by implementation

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:
  • type – Enum class to specify which type of memory allocation method to use

  • data – user allocated buffer pointer

  • size – Size of the buffer

  • deviceDevice handle to be used by implementation

Memory(std::shared_ptr<MemoryImplBase> ptr)#

Memory() - Constructor for using user defined implementation.

Parameters:

ptr – Pointer to user’s implementation instance

~Memory() = default#
const uint8_t *map(DataMapFlags map_flags)#

map() - Maps allocated memory to user space.

Only Memory allocated with XRT/CMA type of memory can be used with map()

Parameters:

map_flags – Flag used to indicate mode of memory mapping

Returns:

returns the virtual address

void unmap()#

unmap() - Unmaps allocated memory from user space

const std::shared_ptr<MemoryImplBase> &get_pimpl_handle() const#

get_pimpl_handle() - Retrieves pointer to Memory Implementation Base class

Returns:

Returns a constant reference of pointer to implementation class.

std::shared_ptr<Device> get_device_handle() const#

get_device_handle() - Retrieves the device handle associated with memory allocation

Returns:

Returns Device handle

size_t get_size()#

get_size() - gets the size of the allocated memory

Returns:

returns the memory size

uint64_t get_physical_addr()#

get_physical_addr() - Retrieves the physical address of the allocated memory if memory type is XRT.

Returns:

returns the physical address

Private Members

std::shared_ptr<MemoryImplBase> pimpl#