aclKernel.h
Go to the documentation of this file.
/*
* Advanced Simulation Library <http://asl.org.il>
*
* Copyright 2015 Avtech Scientific <http://avtechscientific.com>
*
*
* This file is part of Advanced Simulation Library (ASL).
*
* ASL is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3 of the License.
*
* ASL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with ASL. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ACLKERNEL_H
#define ACLKERNEL_H
#include "aclExpressionContainer.h"
#include "aclKernelConfiguration.h"
//#include <CL/cl.hpp>
// Supply "cl.hpp" with ASL, since it is not present in OpenCL 2.0
// Remove the file after switching to OpenCL 2.1
#include "acl/cl.hpp"
namespace acl
{
extern const KernelConfiguration KERNEL_BASIC;
class Kernel: public ExpressionContainer
{
protected:
static unsigned int kernelNum;
unsigned int id;
unsigned int groupsNumber;
KernelConfiguration kernelConfig;
std::string kernelSource;
cl::Kernel kernel;
cl_uint detectVectorWidth();
void generateExtensions();
void generateArguments();
void generateIndex();
void generateLocalDeclarations();
void generateExpressions();
virtual void generateKernelSource();
void updateKernelConfiguration();
void buildKernel();
void setKernelArguments();
public:
explicit Kernel(const KernelConfiguration kernelConfig_ = KERNEL_BASIC);
void setup();
void compute();
void setGroupsNumber(unsigned int n);
unsigned int getGroupsNumber();
std::string getKernelSource();
unsigned int getKernelID();
const cl::Kernel & getKernel() const;
void clear();
inline const KernelConfiguration & getConfiguration()const;
friend class KernelMerger;
};
typedef std::shared_ptr<Kernel> SPKernel;
void inline createKernels(std::vector<SPKernel> & vk,
unsigned int n,
const KernelConfiguration & kernelConfig_ = KERNEL_BASIC);
//---------------------------- Implementation -----------------------------
void inline createKernels(std::vector<SPKernel> & vk,
unsigned int n,
const KernelConfiguration & kernelConfig_)
{
vk.resize(n);
for (unsigned int i(0); i < n; ++i)
{
vk[i].reset(new Kernel(kernelConfig_));
}
}
inline const KernelConfiguration & Kernel::getConfiguration()const
{
return kernelConfig;
}
} // namespace acl
#endif // ACLKERNEL_H
acl::KernelConfiguration
ACL Kernel configuration class.
Definition: aclKernelConfiguration.h:35
acl::Kernel
OpenCl Kernel generator.
Definition: aclKernel.h:49
acl::Kernel::getKernelSource
std::string getKernelSource()
acl::Kernel::generateExtensions
void generateExtensions()
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::getKernel
const cl::Kernel & getKernel() const
acl::Kernel::setKernelArguments
void setKernelArguments()
acl::Kernel::compute
void compute()
acl::Kernel::generateIndex
void generateIndex()
acl::Kernel::updateKernelConfiguration
void updateKernelConfiguration()
acl::Kernel::getConfiguration
const KernelConfiguration & getConfiguration() const
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::kernelNum
static unsigned int kernelNum
Definition: aclKernel.h:51
acl::Kernel::getKernelID
unsigned int getKernelID()
acl::Kernel::groupsNumber
unsigned int groupsNumber
Definition: aclKernel.h:53
acl::Kernel::generateKernelSource
virtual void generateKernelSource()
acl::Kernel::kernelConfig
KernelConfiguration kernelConfig
Definition: aclKernel.h:54
acl::KernelMerger
OpenCl Kernel merger.
Definition: aclKernelMerger.h:46
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
aclExpressionContainer.h
aclKernelConfiguration.h