AQUAgpusph 5.0.4
Loading...
Searching...
No Matches
Aqua::InputOutput::ArrayVariable Class Reference

An array variable. More...

#include <Variable.hpp>

Inheritance diagram for Aqua::InputOutput::ArrayVariable:
Collaboration diagram for Aqua::InputOutput::ArrayVariable:

Public Member Functions

 ArrayVariable (const std::string varname, const std::string vartype)
 ~ArrayVariable ()
bool isArray ()
 Report that the varaible is an array.
size_t typesize () const
size_t size () const
void * get (bool UNUSED_PARAM synced=false)
void set (void *ptr, bool synced=false)
bool reallocatable () const
 Get if a variable is reallocatable.
void reallocatable (bool is)
 Set if a variable is reallocatable.
PyObject * getPythonObject (int i0=0, int n=0)
bool setFromPythonObject (PyObject *obj, int i0=0, int n=0)
const std::string asString (bool synced=true)
const std::string asString (size_t i, bool synced=true)
Public Member Functions inherited from Aqua::InputOutput::Variable
 Variable (const std::string varname, const std::string vartype)
 Constructor.
virtual ~Variable ()
 Destructor.
bool isScalar ()
 Let efficiently know whether the variable is a scalar or not.
std::string name () const
 Name of the variable.
virtual std::string type () const
 Type of the variable.
void * get_async ()
 Get variable pointer basis pointer.
void set_async (void *ptr)
 Set variable from memory.
virtual PyObject * getPythonObject (int UNUSED_PARAM i0=0, int UNUSED_PARAM n=0)
 Get a Python interpretation of the variable.
virtual bool setFromPythonObject (PyObject UNUSED_PARAM *obj, int UNUSED_PARAM i0=0, int UNUSED_PARAM n=0)
 Set the variable from a Python object.
virtual const std::string asString (bool UNUSED_PARAM synced=true)
 Get the variable text representation.
void setEvent (cl_event event)
 Set the variable current writing event.
void setWritingEvent (cl_event event)
 Alias of InputOutput::Variable::setEvent()
cl_event getEvent () const
 Returns the last writing event associated to this variable.
cl_event getWritingEvent () const
 Alias of InputOutput::Variable::getEvent()
void addReadingEvent (cl_event event)
 Add a new reading event to the variable.
std::vector< cl_event > getReadingEvents () const
 Get the list of reading events.
void sync (bool readonly=false)
 Wait for variable reading and writing events to be completed.

Additional Inherited Members

Protected Member Functions inherited from Aqua::InputOutput::Variable
void cleanReadingEvents ()
 Clean up the list of reading events.
Static Protected Member Functions inherited from Aqua::InputOutput::Variable
static cl_event createDummyEvent ()
 Create a competed user event to be set as the writing event when synced writing operations are carried out.

Detailed Description

An array variable.

Constructor & Destructor Documentation

◆ ArrayVariable()

Aqua::InputOutput::ArrayVariable::ArrayVariable ( const std::string varname,
const std::string vartype )

Constructor.

Parameters
varnameName of the variable.
vartypeType of the variable.
Here is the call graph for this function:

◆ ~ArrayVariable()

Aqua::InputOutput::ArrayVariable::~ArrayVariable ( )

Destructor.

Member Function Documentation

◆ asString() [1/2]

const std::string Aqua::InputOutput::ArrayVariable::asString ( bool synced = true)

Get the variable text representation

Parameters
syncedtrue if the function shall block until the last writing event is dispatched, false otherwise
Returns
The variable represented as a string, NULL in case of errors.
Here is the call graph for this function:

◆ asString() [2/2]

const std::string Aqua::InputOutput::ArrayVariable::asString ( size_t i,
bool synced = true )

Get a component text representation

Parameters
iIndex of the component to be extracted.
syncedtrue if the function shall block until the last writing event is dispatched, false otherwise
Returns
The component represented as a string, NULL in case of errors.
Here is the call graph for this function:

◆ get()

void * Aqua::InputOutput::ArrayVariable::get ( bool UNUSED_PARAM synced = false)
inlinevirtual

Get variable pointer basis pointer

Parameters
syncedUnused parameter
Returns
Implementation pointer.

Reimplemented from Aqua::InputOutput::Variable.

◆ getPythonObject()

PyObject * Aqua::InputOutput::ArrayVariable::getPythonObject ( int i0 = 0,
int n = 0 )

Get a PyArrayObject interpretation of the variable

Parameters
i0First component to be read.
nNumber of component to be read, 0 to read all available memory, i.e. All the array after i0.
Returns
PyArrayObject Python object. NULL if the memory cannot be read.
Here is the call graph for this function:

◆ isArray()

bool Aqua::InputOutput::ArrayVariable::isArray ( )
inlinevirtual

Report that the varaible is an array.

Returns
true

Implements Aqua::InputOutput::Variable.

◆ reallocatable() [1/2]

bool Aqua::InputOutput::ArrayVariable::reallocatable ( ) const
inline

Get if a variable is reallocatable.

Returns
true if the variable is marked as reallocatable, false otherwise

◆ reallocatable() [2/2]

void Aqua::InputOutput::ArrayVariable::reallocatable ( bool is)
inline

Set if a variable is reallocatable.

Parameters
istrue if the variable is reallocatable, false otherwise
Note
Non-reallocatable variables are in general way more efficient

◆ set()

void Aqua::InputOutput::ArrayVariable::set ( void * ptr,
bool synced = false )
virtual

Set variable from memory

Parameters
ptrMemory to copy.
syncedUnused parameter
Exceptions
std::runtime_errorif the variable is not reallocatable and it has been already set

Reimplemented from Aqua::InputOutput::Variable.

Here is the call graph for this function:

◆ setFromPythonObject()

bool Aqua::InputOutput::ArrayVariable::setFromPythonObject ( PyObject * obj,
int i0 = 0,
int n = 0 )

Set the variable from a Python object

Parameters
objPyArrayObject object.
i0ignored parameter.
nignored parameter
Returns
false if all gone right, true otherwise.
Here is the call graph for this function:

◆ size()

size_t Aqua::InputOutput::ArrayVariable::size ( ) const
virtual

Get the array size.

Returns
Array allocated memory (in bytes)
Note
In order to get the length of the array the command size() / Variables::typeToBytes(type()) can be used

Reimplemented from Aqua::InputOutput::Variable.

Here is the call graph for this function:

◆ typesize()

size_t Aqua::InputOutput::ArrayVariable::typesize ( ) const
inlinevirtual

Get the cl_mem type size.

Returns
cl_mem type size (in bytes)
Note
In order to know the typesize of the components into the array you may use Variables::typeToBytes()

Reimplemented from Aqua::InputOutput::Variable.


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