ASL
0.1.7
Advanced Simulation Library
Toggle main menu visibility
Loading...
Searching...
No Matches
src
acl
aclUtilities.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 ACLUTILITIES_H
25
#define ACLUTILITIES_H
26
27
#include "
aslUtilities.h
"
28
#include "
Kernels/aclKernelConfiguration.h
"
29
//#include "aclHardware.h"
30
#include "
aclTypes.h
"
31
32
namespace
cl
33
{
34
class
CommandQueue
;
35
}
36
37
namespace
acl
38
{
39
extern
const
std::string
INDEX
;
40
extern
const
KernelConfiguration
KERNEL_BASIC
;
41
42
class
ElementBase
;
43
typedef
std::shared_ptr<ElementBase>
Element
;
44
typedef
std::shared_ptr<cl::CommandQueue>
CommandQueue
;
45
48
bool
compatible
(
unsigned
int
size1,
CommandQueue
queue1,
49
unsigned
int
size2,
CommandQueue
queue2);
50
bool
compatible
(
unsigned
int
size,
CommandQueue
queue,
Element
e);
51
bool
compatible
(
Element
e1,
Element
e2);
52
54
inline
bool
compatibleSizes
(
unsigned
int
s1,
unsigned
int
s2);
56
bool
compatibleSizes
(
Element
e1,
Element
e2);
58
bool
compatibleSizes
(
unsigned
int
s,
Element
e);
59
61
unsigned
int
paddingBytes
(
unsigned
int
size,
62
unsigned
int
typeSize,
63
CommandQueue
queue);
64
66
unsigned
int
paddingElements
(
unsigned
int
size,
67
const
KernelConfiguration
& kernelConfig);
68
70
bool
onSameDevice
(
CommandQueue
queue1,
CommandQueue
queue2);
71
bool
onSameDevice
(
CommandQueue
queue,
Element
e);
72
bool
onSameDevice
(
Element
e1,
Element
e2);
73
74
bool
isDeclarable
(
Element
e);
75
76
bool
isArgument
(
Element
e);
77
79
void
addElementToKernelSource
(
Element
e,
80
std::vector<Element> & arguments,
81
std::vector<Element> & localDeclarations);
82
83
template
<
typename
T>
const
std::string&
typeToStr
();
84
template
<
typename
T>
inline
const
std::string
typeToStr
(
unsigned
int
i);
85
86
template
<
typename
T>
inline
constexpr
const
TypeID
typeToTypeID
();
87
88
// ------------------------Implementation ---------------
89
90
inline
bool
compatibleSizes
(
unsigned
int
s1,
unsigned
int
s2)
91
{
92
return
(s1 == s2 || (s1 * s2) == 0);
93
}
94
95
template
<>
inline
constexpr
const
TypeID
typeToTypeID<cl_double>
()
96
{
97
return
TYPE_DOUBLE
;
98
}
99
100
template
<>
inline
constexpr
const
TypeID
typeToTypeID<cl_float>
()
101
{
102
return
TYPE_FLOAT
;
103
}
104
105
template
<>
inline
constexpr
const
TypeID
typeToTypeID<cl_int>
()
106
{
107
return
TYPE_INT
;
108
}
109
110
template
<>
inline
constexpr
const
TypeID
typeToTypeID<cl_uint>
()
111
{
112
return
TYPE_UINT
;
113
}
114
115
template
<>
inline
constexpr
const
TypeID
typeToTypeID<cl_long>
()
116
{
117
return
TYPE_LONG
;
118
}
119
120
template
<
typename
T>
inline
const
std::string
typeToStr
(
unsigned
int
i)
121
{
122
if
(i == 1)
123
return
typeToStr<T>
();
124
else
125
return
typeToStr<T>
() +
asl::numToStr
(i);
126
}
127
128
129
}
// namespace acl
130
#endif
// ACLUTILITIES_H
aclKernelConfiguration.h
aclTypes.h
aslUtilities.h
useful common utilities
acl::ElementBase
Definition
aclElementBase.h:50
acl::KernelConfiguration
ACL Kernel configuration class.
Definition
aclKernelConfiguration.h:35
cl::CommandQueue
CommandQueue interface for cl_command_queue.
Definition
cl.hpp:5355
acl::KERNEL_BASIC
const KernelConfiguration KERNEL_BASIC
Definition
aclElementBase.h:45
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::CommandQueue
std::shared_ptr< cl::CommandQueue > CommandQueue
Definition
acl.h:51
acl::compatible
bool compatible(unsigned int size1, CommandQueue queue1, unsigned int size2, CommandQueue queue2)
acl::typeToTypeID
constexpr const TypeID typeToTypeID()
acl::onSameDevice
bool onSameDevice(CommandQueue queue1, CommandQueue queue2)
checks whether both elements reside on the same device
acl::paddingBytes
unsigned int paddingBytes(unsigned int size, unsigned int typeSize, CommandQueue queue)
Adds padding in bytes based on the device's alignment.
acl::TypeID
TypeID
Definition
aclTypes.h:39
acl::TYPE_DOUBLE
@ TYPE_DOUBLE
Definition
aclTypes.h:43
acl::TYPE_FLOAT
@ TYPE_FLOAT
Definition
aclTypes.h:42
acl::TYPE_INT
@ TYPE_INT
Definition
aclTypes.h:40
acl::TYPE_LONG
@ TYPE_LONG
Definition
aclTypes.h:44
acl::TYPE_UINT
@ TYPE_UINT
Definition
aclTypes.h:41
acl::paddingElements
unsigned int paddingElements(unsigned int size, const KernelConfiguration &kernelConfig)
Adds padding in elements based on vector width.
acl::isDeclarable
bool isDeclarable(Element e)
acl::typeToStr
const std::string & typeToStr()
acl::compatibleSizes
bool compatibleSizes(unsigned int s, const VectorOfElements &a)
Definition
aclVectorOfElementsDef.h:118
acl::isArgument
bool isArgument(Element e)
acl::addElementToKernelSource
void addElementToKernelSource(Element e, std::vector< Element > &arguments, std::vector< Element > &localDeclarations)
adds e either to arguments or to localDeclarations
acl::Element
std::shared_ptr< ElementBase > Element
Definition
acl.h:49
cl
The OpenCL C++ bindings are defined within this namespace.
Definition
acl.h:34
Generated by
1.18.0