25#ifndef VARIABLE_H_INCLUDED
26#define VARIABLE_H_INCLUDED
41#define PY_ARRAY_UNIQUE_SYMBOL AQUA_ARRAY_API
47#define NO_IMPORT_ARRAY
48#include <numpy/npy_no_deprecated_api.h>
49#include <numpy/ndarraytypes.h>
50#include <numpy/ufuncobject.h>
51#include <numpy/npy_3kcompat.h>
56#ifndef MAX_TYPE_NAME_LEN
57#define MAX_TYPE_NAME_LEN 128
61namespace InputOutput {
74 Variable(
const std::string varname,
const std::string vartype);
97 std::string
name()
const {
return _name; }
102 virtual std::string
type()
const {
return _typename; }
140 virtual void set(
void* ptr,
bool synced =
true);
205 void setEvent(cl_event event);
215 inline cl_event
getEvent()
const {
return _event; }
231 void addReadingEvent(cl_event event);
243 return _reading_events;
256 void sync(
bool readonly =
false);
268 void cleanReadingEvents();
275 static cl_event createDummyEvent();
282 std::string _typename;
288 std::vector<cl_event> _reading_events;
301 bool _synced_for_read;
344 inline void*
get(
bool synced =
true)
375 inline void set(
void* ptr,
bool synced =
true)
379 memcpy(&
_value, ptr,
sizeof(
T));
418 this->
set(value, synced);
441 virtual const std::string
asString(
bool synced) = 0;
473 virtual const std::string asString(
bool synced =
true);
496 PyObject* getPythonObject(
int i0 = 0,
int n = 0);
504 bool setFromPythonObject(PyObject* obj,
int i0 = 0,
int n = 0);
527 PyObject* getPythonObject(
int i0 = 0,
int n = 0);
535 bool setFromPythonObject(PyObject* obj,
int i0 = 0,
int n = 0);
558 PyObject* getPythonObject(
int i0 = 0,
int n = 0);
566 bool setFromPythonObject(PyObject* obj,
int i0 = 0,
int n = 0);
589 PyObject* getPythonObject(
int i0 = 0,
int n = 0);
597 bool setFromPythonObject(PyObject* obj,
int i0 = 0,
int n = 0);
620 PyObject* getPythonObject(
int i0 = 0,
int n = 0);
628 bool setFromPythonObject(PyObject* obj,
int i0 = 0,
int n = 0);
651 PyObject* getPythonObject(
int i0 = 0,
int n = 0);
659 bool setFromPythonObject(PyObject* obj,
int i0 = 0,
int n = 0);
676 const std::string vartype,
677 const unsigned int dims,
689 PyObject* getPythonObject(
int i0 = 0,
int n = 0);
697 bool setFromPythonObject(PyObject* obj,
int i0 = 0,
int n = 0);
704 virtual const std::string asString(
bool synced =
true);
717 bool checkPyhonObjectDims(PyObject* obj);
726#define __DECLARE_AQUA_VEC(NAME, TYPE) \
727 class DECLDIR NAME final : public ScalarVecVariable<TYPE> \
730 NAME(const std::string varname); \
900 ArrayVariable(
const std::string varname,
const std::string vartype);
938 void set(
void* ptr,
bool synced =
false);
957 PyObject* getPythonObject(
int i0 = 0,
int n = 0);
965 bool setFromPythonObject(PyObject* obj,
int i0 = 0,
int n = 0);
972 const std::string asString(
bool synced =
true);
980 const std::string asString(
size_t i,
bool synced =
true);
1005 std::vector<void*> _data;
1011 std::vector<PyObject*> _objects;
1042 const std::string type,
1043 const std::string length,
1044 const std::string value);
1061 std::vector<Variable*>
getAll()
const {
return _vars; }
1066 unsigned int size()
const {
return _vars.size(); }
1072 size_t allocatedMemory();
1078 static size_t typeToBytes(
const std::string type);
1084 static unsigned int typeToN(
const std::string type);
1092 static bool isSameType(
const std::string type_a,
1093 const std::string type_b,
1094 bool ignore_asterisk =
true);
1101 std::vector<Variable*> exprVariables(
const std::string& expr);
1110 void solve(
const std::string type_name,
1111 const std::string value,
1113 const std::string name =
"NULL");
1120 void populate(
const std::string name =
"");
1153 static std::string typeAlias(
const std::string& t);
1162 void registerScalar(
const std::string name,
1163 const std::string type,
1164 const std::string value);
1172 void registerClMem(
const std::string name,
1173 const std::string type,
1174 const std::string length);
1183 template<
typename T>
1184 T solve(
const std::string& name,
const std::string& value);
1187 std::vector<Variable*> _vars;
#define uivec4
Definition LinkList.hcl.in:41
#define dvec8
Definition LinkList.hcl.in:30
#define lvec3
Definition LinkList.hcl.in:36
#define ivec2
Definition LinkList.hcl.in:31
#define dvec2
Definition LinkList.hcl.in:27
#define lvec4
Definition LinkList.hcl.in:37
#define lvec2
Definition LinkList.hcl.in:35
#define ulvec2
Definition LinkList.hcl.in:43
#define uivec3
Definition LinkList.hcl.in:40
#define uivec2
Definition LinkList.hcl.in:39
#define dvec3
Definition LinkList.hcl.in:28
#define ulvec4
Definition LinkList.hcl.in:45
#define lvec8
Definition LinkList.hcl.in:38
#define vec8
Definition LinkList.hcl.in:26
#define ulvec3
Definition LinkList.hcl.in:44
#define uivec8
Definition LinkList.hcl.in:42
#define ulvec8
Definition LinkList.hcl.in:46
#define vec4
Definition LinkList.hcl.in:25
#define ivec3
Definition LinkList.hcl.in:32
#define ivec4
Definition LinkList.hcl.in:33
#define vec2
Definition LinkList.hcl.in:23
#define ivec8
Definition LinkList.hcl.in:34
#define vec3
Definition LinkList.hcl.in:24
#define dvec4
Definition LinkList.hcl.in:29
static PyObject * get(PyObject UNUSED_PARAM *self, PyObject *args, PyObject *keywds)
Get a variable by its name.
Definition Python.cpp:73
static PyObject * set(PyObject UNUSED_PARAM *self, PyObject *args, PyObject *keywds)
Set a variable by its name.
Definition Python.cpp:108
#define T
Definition Sort.hcl.in:83
Math expression evaluator. (See Aqua::Tokenizer for details)
#define __DECLARE_AQUA_VEC(NAME, TYPE)
Definition Variable.hpp:726
cl_event getEvent() const
Returns the last writing event associated to this variable.
Definition Variable.hpp:215
void sync(bool readonly=false)
Wait for variable reading and writing events to be completed.
Definition Variable.cpp:141
std::vector< cl_event > getReadingEvents() const
Get the list of reading events.
Definition Variable.hpp:241
void setEvent(cl_event event)
Set the variable current writing event.
Definition Variable.cpp:75
cl_event getWritingEvent() const
Alias of InputOutput::Variable::getEvent()
Definition Variable.hpp:219
void setWritingEvent(cl_event event)
Alias of InputOutput::Variable::setEvent()
Definition Variable.hpp:209
Main AQUAgpusph namespace.
Definition ArgumentsManager.cpp:50
Tokenizer_exprtk Tokenizer
Definition Tokenizer.hpp:34
Set of definitions and macros related with the implementation.
#define UNUSED_PARAM
Definition sphPrerequisites.hpp:391
#define DECLDIR
Prefix to export C functions on the compiled library.
Definition sphPrerequisites.hpp:65