ASL
0.1.7
Advanced Simulation Library
Toggle main menu visibility
Loading...
Searching...
No Matches
src
acl
DataTypes
aclVariableReference.h
Go to the documentation of this file.
1
/*
2
* Advanced Simulation Library <http://asl.org.il>
3
*
4
* Copyright 2015 Avtech Scientific <http://avtechscientific.com>
5
*
6
*
7
* This file is part of Advanced Simulation Library (ASL).
8
*
9
* ASL is free software: you can redistribute it and/or modify it
10
* under the terms of the GNU Affero General Public License as
11
* published by the Free Software Foundation, version 3 of the License.
12
*
13
* ASL is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU Affero General Public License for more details.
17
*
18
* You should have received a copy of the GNU Affero General Public License
19
* along with ASL. If not, see <http://www.gnu.org/licenses/>.
20
*
21
*/
22
23
24
#ifndef ACLVARIABLEREFERENCE_H
25
#define ACLVARIABLEREFERENCE_H
26
27
#include "
../aclElementBase.h
"
28
#include "
../../aslUtilities.h
"
29
#include "
../aclUtilities.h
"
30
31
using namespace
asl
;
32
33
namespace
acl
34
{
35
36
template
<
typename
T>
class
VariableReference
:
public
ElementBase
37
{
38
private
:
39
T & value;
40
string
name;
41
static
const
string
prefix;
42
static
unsigned
int
id;
43
public
:
44
explicit
VariableReference
(T & v);
45
virtual
string
str
(
const
KernelConfiguration
& kernelConfig)
const
;
46
virtual
string
getName
()
const
;
47
virtual
string
getTypeSignature
(
const
KernelConfiguration
& kernelConfig)
const
;
48
virtual
string
getLocalDeclaration
(
const
KernelConfiguration
& kernelConfig)
const
;
49
virtual
void
addToKernelSource
(vector<Element> & arguments,
50
vector<Element> & localDeclarations)
const
;
51
virtual
void
setAsArgument
(
cl::Kernel
& kernel,
unsigned
int
argumentIndex)
const
;
52
};
53
54
55
template
<
typename
T>
VariableReference<T>::VariableReference
(T & v):
56
ElementBase
(true, 0,
typeToTypeID
<T>()),
57
value(v)
58
{
59
++id;
60
name = prefix +
asl::numToStr
(
id
);
61
}
62
63
64
template
<
typename
T>
string
VariableReference<T>::getName
()
const
65
{
66
return
name;
67
}
68
69
70
template
<
typename
T>
string
VariableReference<T>::str
(
const
KernelConfiguration
& kernelConfig)
const
71
{
72
return
name;
73
}
74
75
76
template
<
typename
T>
string
VariableReference<T>::getLocalDeclaration
(
const
KernelConfiguration
& kernelConfig)
const
77
{
78
return
""
;
79
}
80
81
82
template
<
typename
T>
void
VariableReference<T>::addToKernelSource
(vector<Element> & arguments,
83
vector<Element> & localDeclarations)
const
84
{
85
}
86
87
template
<
typename
T>
void
VariableReference<T>::setAsArgument
(
cl::Kernel
& kernel,
unsigned
int
argumentIndex)
const
88
{
89
cl_int status = 0;
90
status = kernel.
setArg
(argumentIndex, value);
91
errorMessage
(status,
"Kernel::setArg() - "
+ name +
", argument "
+
asl::numToStr
(argumentIndex));
92
}
93
94
95
}
// namespace acl
96
97
#endif
// ACLVARIABLE_H
aclElementBase.h
aclUtilities.h
aslUtilities.h
useful common utilities
acl::ElementBase::ElementBase
ElementBase(bool isWritable_, unsigned int size_, TypeID typeID_)
acl::KernelConfiguration
ACL Kernel configuration class.
Definition
aclKernelConfiguration.h:35
acl::VariableReference::getName
virtual string getName() const
Definition
aclVariableReference.h:64
acl::VariableReference::str
virtual string str(const KernelConfiguration &kernelConfig) const
Definition
aclVariableReference.h:70
acl::VariableReference::addToKernelSource
virtual void addToKernelSource(vector< Element > &arguments, vector< Element > &localDeclarations) const
Definition
aclVariableReference.h:82
acl::VariableReference::VariableReference
VariableReference(T &v)
Definition
aclVariableReference.h:55
acl::VariableReference::getTypeSignature
virtual string getTypeSignature(const KernelConfiguration &kernelConfig) const
acl::VariableReference::setAsArgument
virtual void setAsArgument(cl::Kernel &kernel, unsigned int argumentIndex) const
Definition
aclVariableReference.h:87
acl::VariableReference::getLocalDeclaration
virtual string getLocalDeclaration(const KernelConfiguration &kernelConfig) const
Definition
aclVariableReference.h:76
cl::Kernel
Class interface for cl_kernel.
Definition
cl.hpp:4722
cl::Kernel::setArg
cl_int setArg(cl_uint index, const T &value)
Definition
cl.hpp:4845
asl::errorMessage
void errorMessage(cl_int status, const char *errorMessage)
Prints errorMessage and exits depending on the status.
asl::numToStr
std::string numToStr(T i)
Converts numbers or another type to string.
Definition
aslUtilities.h:48
acl
Advanced Computational Language.
Definition
acl.h:41
acl::typeToTypeID
constexpr const TypeID typeToTypeID()
asl
Advanced Simulation Library.
Definition
aslDataInc.h:31
Generated by
1.17.0