Debian Codegraph @

src/acl/DataTypes/aclPrivateVariable.h

raw
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 ACLPRIVATEVARIABLE_H
25 #define ACLPRIVATEVARIABLE_H
26
27 #include "../aclElementBase.h"
28 #include "../../aslUtilities.h"
29 #include "../aclUtilities.h"
30
31 namespace acl
32 {
33 /**
34 This Element appears in the Kernel source code
35 as a private variable (without address space qualifier).
36 It is not passed to the Kernel as an argument.
37 */
38 template <typename T> class PrivateVariable: public ElementBase
39 {
40 private:
41 string name;
42 static const string prefix;
43 static unsigned int id;
44 public:
45 PrivateVariable();
46 virtual string str(const KernelConfiguration & kernelConfig) const;
47 virtual string getName() const;
48 virtual string getAddressSpaceQualifier() const;
49 virtual string getTypeSignature(const KernelConfiguration & kernelConfig) const;
50 virtual string getLocalDeclaration(const KernelConfiguration & kernelConfig) const;
51 virtual void addToKernelSource(vector<Element> & arguments,
52 vector<Element> & localDeclarations) const;
53 virtual void setAsArgument(cl::Kernel & kernel, unsigned int argumentIndex) const;
54 };
55
56
57 template <typename T> PrivateVariable<T>::PrivateVariable():
58 ElementBase(true, 0, typeToTypeID<T>())
59 {
60 ++id;
61 name = prefix + asl::numToStr(id);
62 }
63
64
65 template <typename T> string PrivateVariable<T>::str(const KernelConfiguration & kernelConfig) const
66 {
67 return name;
68 }
69
70 template <typename T> string PrivateVariable<T>::getName() const
71 {
72 return name;
73 }
74
75
76 template <typename T> string PrivateVariable<T>::getAddressSpaceQualifier() const
77 {
78 return "__private";
79 }
80
81
82 template <typename T> string PrivateVariable<T>::getTypeSignature(const KernelConfiguration & kernelConfig) const
83 {
84 return "";
85 }
86
87
88 template <typename T> string PrivateVariable<T>::getLocalDeclaration(const KernelConfiguration & kernelConfig) const
89 {
90 return typeToStr<T>(kernelConfig.vectorWidth) + " " + name;
91 }
92
93
94 template <typename T> void PrivateVariable<T>::addToKernelSource(vector<Element> & arguments,
95 vector<Element> & localDeclarations) const
96 {
97 }
98
99
100 /// can't be set as an argument
101 template <typename T> void PrivateVariable<T>::setAsArgument(cl::Kernel & kernel,
102 unsigned int argumentIndex) const
103 {
104 }
105
106 } // namespace acl
107
108 #endif /* ACLPRIVATEVARIABLE_H */
109