ASL
0.1.7
Advanced Simulation Library
Toggle main menu visibility
Loading...
Searching...
No Matches
src
acl
DataTypes
aclPrivateArray.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 ACLPRIVATEARRAY_H
25
#define ACLPRIVATEARRAY_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
42
template
<
typename
T>
class
PrivateArray
:
public
ElementBase
43
{
44
private
:
45
string
name;
46
static
const
string
prefix;
47
static
unsigned
int
id;
48
vector<T> initVector;
49
public
:
50
explicit
PrivateArray
(
const
vector<T> & initVector_);
51
virtual
string
str
(
const
KernelConfiguration
& kernelConfig)
const
;
52
virtual
string
getName
()
const
;
53
virtual
string
getAddressSpaceQualifier
()
const
;
54
virtual
string
getTypeSignature
(
const
KernelConfiguration
& kernelConfig)
const
;
55
virtual
string
getLocalDeclaration
(
const
KernelConfiguration
& kernelConfig)
const
;
56
virtual
void
addToKernelSource
(vector<Element> & arguments,
57
vector<Element> & localDeclarations)
const
;
58
virtual
void
setAsArgument
(
cl::Kernel
& kernel,
unsigned
int
argumentIndex)
const
;
59
};
60
61
62
template
<
typename
T>
PrivateArray<T>::PrivateArray
(
const
vector<T> & initVector_):
63
ElementBase
(true, initVector_.
size
(),
typeToTypeID
<T>()),
64
initVector(initVector_)
65
{
66
++id;
67
name = prefix +
asl::numToStr
(
id
);
68
}
69
70
71
template
<
typename
T>
string
PrivateArray<T>::str
(
const
KernelConfiguration
& kernelConfig)
const
72
{
73
if
(kernelConfig.
vectorWidth
> 1)
74
{
75
errorMessage
(
"PrivateArray should not be used in a SIMD Kernel"
);
76
return
""
;
77
}
78
else
79
return
name +
"["
+
INDEX
+
"]"
;
80
}
81
82
83
template
<
typename
T>
string
PrivateArray<T>::getName
()
const
84
{
85
return
name;
86
}
87
88
89
template
<
typename
T>
string
PrivateArray<T>::getTypeSignature
(
const
KernelConfiguration
& kernelConfig)
const
90
{
91
return
""
;
92
}
93
94
95
template
<
typename
T>
string
PrivateArray<T>::getAddressSpaceQualifier
()
const
96
{
97
return
"__private"
;
98
}
99
100
101
template
<
typename
T>
string
PrivateArray<T>::getLocalDeclaration
(
const
KernelConfiguration
& kernelConfig)
const
102
{
103
string
s =
typeToStr<T>
() +
" "
+ name +
"["
+
asl::numToStr
(
size
) +
"] = {"
;
104
105
for
(
unsigned
int
i = 0; i <
size
; ++i)
106
s +=
numToStr
(initVector[i]) +
", "
;
107
108
// drop last ", "
109
s.erase(s.size() - 2);
110
s +=
"}"
;
111
112
return
s;
113
}
114
115
116
template
<
typename
T>
void
PrivateArray<T>::addToKernelSource
(vector<Element> & arguments,
117
vector<Element> & localDeclarations)
const
118
{
119
}
120
121
122
// can't be set as an argument
123
template
<
typename
T>
void
PrivateArray<T>::setAsArgument
(
cl::Kernel
& kernel,
124
unsigned
int
argumentIndex)
const
125
{
126
}
127
128
129
}
// namespace acl
130
131
#endif
// ACLPRIVATEARRAY_H
aclElementBase.h
aclUtilities.h
aslUtilities.h
useful common utilities
acl::ElementBase::ElementBase
ElementBase(bool isWritable_, unsigned int size_, TypeID typeID_)
acl::ElementBase::size
unsigned int size
Definition
aclElementBase.h:52
acl::KernelConfiguration
ACL Kernel configuration class.
Definition
aclKernelConfiguration.h:35
acl::KernelConfiguration::vectorWidth
unsigned int vectorWidth
Definition
aclKernelConfiguration.h:43
acl::PrivateArray::setAsArgument
virtual void setAsArgument(cl::Kernel &kernel, unsigned int argumentIndex) const
Definition
aclPrivateArray.h:123
acl::PrivateArray::getAddressSpaceQualifier
virtual string getAddressSpaceQualifier() const
Definition
aclPrivateArray.h:95
acl::PrivateArray::PrivateArray
PrivateArray(const vector< T > &initVector_)
Definition
aclPrivateArray.h:62
acl::PrivateArray::addToKernelSource
virtual void addToKernelSource(vector< Element > &arguments, vector< Element > &localDeclarations) const
Definition
aclPrivateArray.h:116
acl::PrivateArray::getTypeSignature
virtual string getTypeSignature(const KernelConfiguration &kernelConfig) const
Definition
aclPrivateArray.h:89
acl::PrivateArray::getName
virtual string getName() const
Definition
aclPrivateArray.h:83
acl::PrivateArray::getLocalDeclaration
virtual string getLocalDeclaration(const KernelConfiguration &kernelConfig) const
Definition
aclPrivateArray.h:101
acl::PrivateArray::str
virtual string str(const KernelConfiguration &kernelConfig) const
Definition
aclPrivateArray.h:71
cl::Kernel
Class interface for cl_kernel.
Definition
cl.hpp:4722
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::INDEX
const std::string INDEX
Definition
aclUtilities.h:39
acl::typeToTypeID
constexpr const TypeID typeToTypeID()
acl::typeToStr
const std::string & typeToStr()
asl
Advanced Simulation Library.
Definition
aslDataInc.h:31
Generated by
1.17.0