rexlib 0.1.0
Device-agnostic array computing library for CryoEM and CryoET image processing, with a pluggable backend architecture
Loading...
Searching...
No Matches
Public Member Functions | List of all members
rexlib::buffer Class Referenceabstract

Represents an untyped memory allocation at a given memory resource. More...

#include <rexlib/core/hardware/buffer.hpp>

Public Member Functions

 buffer (const buffer &other)=delete
 
 buffer (buffer &&other) noexcept=delete
 
buffer & operator= (const buffer &other)=delete
 
buffer & operator= (buffer &&other) noexcept=delete
 
virtual void * get_host_ptr () noexcept=0
 Get a host accessible pointer to the data.
 
virtual const void * get_host_ptr () const noexcept=0
 Get a host accessible pointer to the data.
 
virtual std::size_t get_size () const noexcept=0
 Get the size in bytes for this buffer.
 
virtual const memory_resource & get_memory_resource () const noexcept=0
 Get the memory resource where this buffer is stored.
 

Detailed Description

Represents an untyped memory allocation at a given memory resource.

A buffer is a handle to a contiguous block of memory. It carries no type information of its own.

Member Function Documentation

◆ get_host_ptr() [1/2]

virtual const void * rexlib::buffer::get_host_ptr ( ) const
pure virtualnoexcept

Get a host accessible pointer to the data.

Const overload of get_host_ptr(); see that method for the conditions under which a non-null pointer is returned and the lifetime/synchronization guarantees that apply.

Returns
const void* Pointer to the start of the buffer's data, or nullptr if the buffer is not host accessible.

◆ get_host_ptr() [2/2]

virtual void * rexlib::buffer::get_host_ptr ( )
pure virtualnoexcept

Get a host accessible pointer to the data.

This method only returns a non-null pointer if the data is directly addressable by the host, i.e. when the kind of the underlying memory_resource is one of: device_mapped, host_staging, host, unified or managed. For pure device-only resources the buffer must be transferred to a host-accessible buffer first.

The returned pointer is valid for as long as this buffer instance is alive and is aligned to the alignment requested at allocation time. Reads or writes through it may need to be preceded by appropriate synchronization with any in-flight device-side work that uses the same buffer.

Returns
void* Pointer to the start of the buffer's data, or nullptr if the buffer is not host accessible.

◆ get_memory_resource()

virtual const memory_resource & rexlib::buffer::get_memory_resource ( ) const
pure virtualnoexcept

Get the memory resource where this buffer is stored.

Returns
const memory_resource& The resource backing the buffer.

◆ get_size()

virtual std::size_t rexlib::buffer::get_size ( ) const
pure virtualnoexcept

Get the size in bytes for this buffer.

The size may be larger then the requested in memory_allocator::allocate.

Returns
std::size_t Size in bytes.

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