ASL
0.1.7
Advanced Simulation Library
Toggle main menu visibility
Loading...
Searching...
No Matches
src
acl
Kernels
aclKernel.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 ACLKERNEL_H
25
#define ACLKERNEL_H
26
27
#include "
aclExpressionContainer.h
"
28
#include "
aclKernelConfiguration.h
"
29
//#include <CL/cl.hpp>
30
// Supply "cl.hpp" with ASL, since it is not present in OpenCL 2.0
31
// Remove the file after switching to OpenCL 2.1
32
#include "
acl/cl.hpp
"
33
34
namespace
acl
35
{
36
37
extern
const
KernelConfiguration
KERNEL_BASIC
;
38
40
48
class
Kernel
:
public
ExpressionContainer
49
{
50
protected
:
51
static
unsigned
int
kernelNum
;
52
unsigned
int
id
;
53
unsigned
int
groupsNumber
;
54
KernelConfiguration
kernelConfig
;
55
std::string
kernelSource
;
56
cl::Kernel
kernel
;
57
59
cl_uint
detectVectorWidth
();
60
void
generateExtensions
();
61
void
generateArguments
();
62
void
generateIndex
();
63
void
generateLocalDeclarations
();
64
void
generateExpressions
();
65
virtual
void
generateKernelSource
();
66
void
updateKernelConfiguration
();
67
void
buildKernel
();
68
void
setKernelArguments
();
69
public
:
70
explicit
Kernel
(
const
KernelConfiguration
kernelConfig_ =
KERNEL_BASIC
);
74
void
setup
();
75
void
compute
();
76
void
setGroupsNumber
(
unsigned
int
n);
77
unsigned
int
getGroupsNumber
();
78
std::string
getKernelSource
();
79
unsigned
int
getKernelID
();
80
const
cl::Kernel
&
getKernel
()
const
;
82
void
clear
();
83
inline
const
KernelConfiguration
&
getConfiguration
()
const
;
84
85
friend
class
KernelMerger
;
86
};
87
89
typedef
std::shared_ptr<Kernel>
SPKernel
;
90
93
void
inline
createKernels
(std::vector<SPKernel> & vk,
94
unsigned
int
n,
95
const
KernelConfiguration
& kernelConfig_ =
KERNEL_BASIC
);
96
97
98
//---------------------------- Implementation -----------------------------
99
100
void
inline
createKernels
(std::vector<SPKernel> & vk,
101
unsigned
int
n,
102
const
KernelConfiguration
& kernelConfig_)
103
{
104
vk.resize(n);
105
for
(
unsigned
int
i(0); i < n; ++i)
106
{
107
vk[i].reset(
new
Kernel
(kernelConfig_));
108
}
109
}
110
111
inline
const
KernelConfiguration
&
Kernel::getConfiguration
()
const
112
{
113
return
kernelConfig
;
114
}
115
116
117
}
// namespace acl
118
119
#endif
// ACLKERNEL_H
aclExpressionContainer.h
aclKernelConfiguration.h
cl.hpp
C++ bindings for OpenCL 1.0 (rev 48), OpenCL 1.1 (rev 33) and OpenCL 1.2 (rev 15).
acl::ExpressionContainer::ExpressionContainer
ExpressionContainer()
acl::KernelConfiguration
ACL Kernel configuration class.
Definition
aclKernelConfiguration.h:35
acl::Kernel::getKernelSource
std::string getKernelSource()
acl::Kernel::generateExtensions
void generateExtensions()
acl::Kernel::getKernel
const cl::Kernel & getKernel() const
acl::Kernel::detectVectorWidth
cl_uint detectVectorWidth()
detects minimal vector width of all available types of Elements
acl::Kernel::buildKernel
void buildKernel()
acl::Kernel::getConfiguration
const KernelConfiguration & getConfiguration() const
Definition
aclKernel.h:111
acl::Kernel::setGroupsNumber
void setGroupsNumber(unsigned int n)
acl::Kernel::setup
void setup()
acl::Kernel::kernel
cl::Kernel kernel
Definition
aclKernel.h:56
acl::Kernel::id
unsigned int id
Definition
aclKernel.h:52
acl::Kernel::getGroupsNumber
unsigned int getGroupsNumber()
acl::Kernel::clear
void clear()
removes all expressions from the kernel
acl::Kernel::Kernel
Kernel(const KernelConfiguration kernelConfig_=KERNEL_BASIC)
acl::Kernel::KernelMerger
friend class KernelMerger
Definition
aclKernel.h:85
acl::Kernel::setKernelArguments
void setKernelArguments()
acl::Kernel::compute
void compute()
acl::Kernel::generateIndex
void generateIndex()
acl::Kernel::updateKernelConfiguration
void updateKernelConfiguration()
acl::Kernel::generateExpressions
void generateExpressions()
acl::Kernel::kernelSource
std::string kernelSource
Definition
aclKernel.h:55
acl::Kernel::SPKernel
std::shared_ptr< Kernel > SPKernel
Definition
aclKernel.h:89
acl::Kernel::generateLocalDeclarations
void generateLocalDeclarations()
acl::Kernel::generateArguments
void generateArguments()
acl::Kernel::getKernelID
unsigned int getKernelID()
acl::Kernel::groupsNumber
unsigned int groupsNumber
Definition
aclKernel.h:53
acl::Kernel::kernelNum
static unsigned int kernelNum
Definition
aclKernel.h:51
acl::Kernel::generateKernelSource
virtual void generateKernelSource()
acl::Kernel::kernelConfig
KernelConfiguration kernelConfig
Definition
aclKernel.h:54
cl::Kernel
Class interface for cl_kernel.
Definition
cl.hpp:4722
acl::KERNEL_BASIC
const KernelConfiguration KERNEL_BASIC
Definition
aclElementBase.h:45
acl
Advanced Computational Language.
Definition
acl.h:41
acl::createKernels
void createKernels(std::vector< SPKernel > &vk, unsigned int n, const KernelConfiguration &kernelConfig_)
Definition
aclKernel.h:100
Generated by
1.17.0