ASL 0.1.7
Advanced Simulation Library
Loading...
Searching...
No Matches
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
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
34namespace 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;
57
65 virtual void generateKernelSource();
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();
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
ACL Kernel configuration class.
OpenCl Kernel generator.
Definition aclKernel.h:49
std::string getKernelSource()
void generateExtensions()
const cl::Kernel & getKernel() const
cl_uint detectVectorWidth()
detects minimal vector width of all available types of Elements
void buildKernel()
const KernelConfiguration & getConfiguration() const
void setGroupsNumber(unsigned int n)
void setup()
cl::Kernel kernel
Definition aclKernel.h:56
unsigned int id
Definition aclKernel.h:52
unsigned int getGroupsNumber()
void clear()
removes all expressions from the kernel
Kernel(const KernelConfiguration kernelConfig_=KERNEL_BASIC)
void setKernelArguments()
void compute()
void generateIndex()
void updateKernelConfiguration()
void generateExpressions()
std::string kernelSource
Definition aclKernel.h:55
std::shared_ptr< Kernel > SPKernel
Definition aclKernel.h:89
void generateLocalDeclarations()
void generateArguments()
static unsigned int kernelNum
Definition aclKernel.h:51
unsigned int getKernelID()
unsigned int groupsNumber
Definition aclKernel.h:53
virtual void generateKernelSource()
KernelConfiguration kernelConfig
Definition aclKernel.h:54
OpenCl Kernel merger.
Class interface for cl_kernel.
Definition cl.hpp:4722
const KernelConfiguration KERNEL_BASIC
Advanced Computational Language.
Definition acl.h:41
void createKernels(std::vector< SPKernel > &vk, unsigned int n, const KernelConfiguration &kernelConfig_)
Definition aclKernel.h:100