Intel clGPU
buffer_binding Class Reference

Binds host data and memory buffers per engine describing data direction (in/out) for kernel. More...

#include <engine.hpp>

Public Member Functions

 buffer_binding (void *ptr, size_t size=0, direction dir=inout)
 Constructs binding from host-allocated buffer. More...
 
 buffer_binding (const std::shared_ptr< buffer > &buffer, direction dir=inout, size_t size=0)
 Constructs binding from engine-allocated memory buffer. More...
 
direction get_direction () const
 Get direction of the binding.
 
direction set_direction (direction dir)
 Set direction of the binding. More...
 
const std::shared_ptr< engine > & get_owning_engine () const
 Returns engine of the buffer passed to constructor or NULL if consrtucted from host-allocated data.
 
void * get_host_ptr () const
 Raw pointer to data. More...
 
void reset_host_ptr () const
 Reset internal host pointer to NULL if constructed from buffer.
 
size_t size () const
 Returns size of data.
 
size_t capacity () const
 Returns maximum possible size value.
 
void size (size_t size)
 Set new size. More...
 
std::shared_ptr< bufferget_buffer (const std::shared_ptr< engine > &engine) const
 Returns binded buffer for the specified engine. More...
 
bool is_output () const
 
bool is_input () const
 
bool is_defined () const
 Check if binding is fully defined: size is set and constructed from correct host-allocated pointer of buffer.
 

Protected Attributes

direction _direction
 
void * _host_ptr
 
size_t _capacity
 
size_t _size
 
std::shared_ptr< engine_owning_engine
 
std::map< std::shared_ptr< engine >, std::shared_ptr< buffer > > _buffers
 

Detailed Description

Binds host data and memory buffers per engine describing data direction (in/out) for kernel.

Definition at line 126 of file engine.hpp.

Constructor & Destructor Documentation

◆ buffer_binding() [1/2]

buffer_binding ( void *  ptr,
size_t  size = 0,
direction  dir = inout 
)
inline

Constructs binding from host-allocated buffer.

Parameters
ptrRaw pointer to host allocated data
sizeSize of host allocated data
dirData direction: host->kernel or host<-kernel or both

Definition at line 134 of file engine.hpp.

◆ buffer_binding() [2/2]

buffer_binding ( const std::shared_ptr< buffer > &  buffer,
direction  dir = inout,
size_t  size = 0 
)
inline

Constructs binding from engine-allocated memory buffer.

Parameters
bufferPre-allocated memory buffer
dirData direction: host->kernel or host<-kernel or both
sizeSize of data to be used - should be less or equal to buffer size, if set to 0 then buffer size will be used.

Definition at line 149 of file engine.hpp.

Member Function Documentation

◆ get_buffer()

std::shared_ptr<buffer> get_buffer ( const std::shared_ptr< engine > &  engine) const

Returns binded buffer for the specified engine.

If there is no buffer binded - create and register new binded buffer

◆ get_host_ptr()

void* get_host_ptr ( ) const

Raw pointer to data.

Returns
Host-allocated pointer or mapped buffer depending on constrcution.

◆ set_direction()

direction set_direction ( direction  dir)

Set direction of the binding.

Returns
Previous value

◆ size()

void size ( size_t  size)

Set new size.

New size should be less or equal to capacity


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