ASL
0.1.7
Advanced Simulation Library
Toggle main menu visibility
Loading...
Searching...
No Matches
src
acl
DataTypes
aclLocalArray.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 ACLLOCALARRAY_H
25
#define ACLLOCALARRAY_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
41
template
<
typename
T>
class
LocalArray
:
public
ElementBase
42
{
43
private
:
44
string
name;
45
static
const
string
prefix;
46
static
unsigned
int
id;
47
public
:
48
explicit
LocalArray
(
unsigned
int
size_);
49
virtual
string
str
(
const
KernelConfiguration
& kernelConfig)
const
;
50
virtual
string
getName
()
const
;
51
virtual
string
getAddressSpaceQualifier
()
const
;
52
virtual
string
getTypeSignature
(
const
KernelConfiguration
& kernelConfig)
const
;
53
virtual
string
getLocalDeclaration
(
const
KernelConfiguration
& kernelConfig)
const
;
54
virtual
void
addToKernelSource
(vector<Element> & arguments,
55
vector<Element> & localDeclarations)
const
;
56
virtual
void
setAsArgument
(
cl::Kernel
& kernel,
unsigned
int
argumentIndex)
const
;
57
};
58
59
60
template
<
typename
T>
LocalArray<T>::LocalArray
(
unsigned
int
size_):
61
ElementBase
(true, size_,
typeToTypeID
<T>())
62
{
63
++id;
64
name = prefix +
asl::numToStr
(
id
);
65
}
66
67
68
template
<
typename
T>
string
LocalArray<T>::str
(
const
KernelConfiguration
& kernelConfig)
const
69
{
70
if
(kernelConfig.
unaligned
&& kernelConfig.
vectorWidth
> 1)
71
{
72
return
"vload"
+
numToStr
(kernelConfig.
vectorWidth
) +
"(0, &"
+ name +
"["
+
INDEX
+
"])"
;
73
}
74
else
75
{
76
return
name +
"["
+
INDEX
+
"]"
;
77
}
78
}
79
80
81
template
<
typename
T>
string
LocalArray<T>::getName
()
const
82
{
83
return
name;
84
}
85
86
87
template
<
typename
T>
string
LocalArray<T>::getTypeSignature
(
const
KernelConfiguration
& kernelConfig)
const
88
{
89
return
""
;
90
}
91
92
93
template
<
typename
T>
string
LocalArray<T>::getAddressSpaceQualifier
()
const
94
{
95
return
"__local"
;
96
}
97
98
99
template
<
typename
T>
string
LocalArray<T>::getLocalDeclaration
(
const
KernelConfiguration
& kernelConfig)
const
100
{
101
return
"__local "
+
typeToStr<T>
(kernelConfig.
unaligned
? 1 : kernelConfig.
vectorWidth
)
102
+
" "
+ name +
"["
+
asl::numToStr
(
size
+
paddingElements
(
size
, kernelConfig)) +
"]"
;
103
}
104
105
106
template
<
typename
T>
void
LocalArray<T>::addToKernelSource
(vector<Element> & arguments,
107
vector<Element> & localDeclarations)
const
108
{
109
}
110
111
112
// can't be set as an argument
113
template
<
typename
T>
void
LocalArray<T>::setAsArgument
(
cl::Kernel
& kernel,
114
unsigned
int
argumentIndex)
const
115
{
116
}
117
118
119
}
// namespace acl
120
121
#endif
// ACLLOCALARRAY_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::unaligned
bool unaligned
Definition
aclKernelConfiguration.h:44
acl::KernelConfiguration::vectorWidth
unsigned int vectorWidth
Definition
aclKernelConfiguration.h:43
acl::LocalArray::setAsArgument
virtual void setAsArgument(cl::Kernel &kernel, unsigned int argumentIndex) const
Definition
aclLocalArray.h:113
acl::LocalArray::getAddressSpaceQualifier
virtual string getAddressSpaceQualifier() const
Definition
aclLocalArray.h:93
acl::LocalArray::LocalArray
LocalArray(unsigned int size_)
Definition
aclLocalArray.h:60
acl::LocalArray::getLocalDeclaration
virtual string getLocalDeclaration(const KernelConfiguration &kernelConfig) const
Definition
aclLocalArray.h:99
acl::LocalArray::getName
virtual string getName() const
Definition
aclLocalArray.h:81
acl::LocalArray::addToKernelSource
virtual void addToKernelSource(vector< Element > &arguments, vector< Element > &localDeclarations) const
Definition
aclLocalArray.h:106
acl::LocalArray::str
virtual string str(const KernelConfiguration &kernelConfig) const
Definition
aclLocalArray.h:68
acl::LocalArray::getTypeSignature
virtual string getTypeSignature(const KernelConfiguration &kernelConfig) const
Definition
aclLocalArray.h:87
cl::Kernel
Class interface for cl_kernel.
Definition
cl.hpp:4722
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::paddingElements
unsigned int paddingElements(unsigned int size, const KernelConfiguration &kernelConfig)
Adds padding in elements based on vector width.
acl::typeToStr
const std::string & typeToStr()
asl
Advanced Simulation Library.
Definition
aslDataInc.h:31
Generated by
1.17.0