![]() |
Clover Git
OpenCL 1.1 software implementation
|
#include <kernel.h>
Inheritance diagram for Coal::Kernel:
Collaboration diagram for Coal::Kernel:Classes | |
| class | Arg |
| Kernel argument. More... | |
| struct | DeviceDependent |
Public Member Functions | |
| Kernel (Program *program) | |
| Constructor. | |
| ~Kernel () | |
| cl_int | addFunction (DeviceInterface *device, llvm::Function *function, llvm::Module *module) |
Add a llvm::Function to this kernel. | |
| llvm::Function * | function (DeviceInterface *device) const |
Get the LLVM function for a specified device. | |
| cl_int | setArg (cl_uint index, size_t size, const void *value) |
| Set the value of an argument. | |
| unsigned int | numArgs () const |
| Number of arguments of this kernel. | |
| const Arg & | arg (unsigned int index) const |
Arg at the given index | |
| DeviceKernel * | deviceDependentKernel (DeviceInterface *device) const |
Coal::DeviceKernel for the specified device | |
| bool | argsSpecified () const |
true if all the arguments have been set through setArg() | |
| bool | hasLocals () const |
true if one or more argument is in file Arg::Local | |
| cl_int | info (cl_kernel_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret) const |
| Get information about this kernel. | |
| cl_int | workGroupInfo (DeviceInterface *device, cl_kernel_work_group_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret) const |
| Get performance hints and device-specific data about this kernel. | |
Private Member Functions | |
| const DeviceDependent & | deviceDependent (DeviceInterface *device) const |
| DeviceDependent & | deviceDependent (DeviceInterface *device) |
Private Attributes | |
| std::string | p_name |
| bool | p_has_locals |
| std::vector< DeviceDependent > | p_device_dependent |
| std::vector< Arg > | p_args |
| DeviceDependent | null_dep |
A kernel represents a LLVM function that can be run on a device. As Coal::Kernel objects are device-independent, they in fact represent only the name of a kernel and the arguments the application wants to pass to it, but it also contains a list of LLVM functions for each device for which its parent Coal::Program has been built
| Kernel::Kernel | ( | Program * | program | ) |
Constructor.
| program | Parent Coal::Program |
Definition at line 51 of file kernel.cpp.
References Coal::Kernel::DeviceDependent::device, Coal::Kernel::DeviceDependent::function, Coal::Kernel::DeviceDependent::kernel, Coal::Kernel::DeviceDependent::module, and null_dep.
| Kernel::~Kernel | ( | ) |
Definition at line 62 of file kernel.cpp.
References Coal::Kernel::DeviceDependent::kernel, and p_device_dependent.
| cl_int Kernel::addFunction | ( | DeviceInterface * | device, |
| llvm::Function * | function, | ||
| llvm::Module * | module | ||
| ) |
Add a llvm::Function to this kernel.
This function adds a llvm::Function to this kernel for the specified device. It also has the responsibility to find the Arg::Kind of each of the function's arguments.
LLVM provides a llvm::Type for each argument:
Arg::Buffer and its field is a simple cast from a LLVM addrspace to Arg::File.%struct.image2d or %struct.image3d, kind is set to Arg::Image2D or Arg::Image3D, respectively.vec_dim is set to the vector size, and the rest of the computations are done on the element typeArg::Kind. For instance, i32 becomes Arg::Int32 Samplers aren't detected at this stage because they are plain i32 types on the LLVM side. They are detected in setArg() when the value being set to the argument appears to be a Coal::Sampler.
| device | device for which the function is added |
| function | function to add |
| module | LLVM module of this function |
Definition at line 100 of file kernel.cpp.
References Coal::Kernel::Arg::Buffer, Coal::DeviceInterface::createDeviceKernel(), Coal::Kernel::DeviceDependent::device, Coal::Kernel::Arg::Double, Coal::Kernel::Arg::Float, function(), Coal::Kernel::DeviceDependent::function, Coal::Kernel::Arg::Global, Coal::Kernel::Arg::Image2D, Coal::Kernel::Arg::Image3D, Coal::Kernel::Arg::Int16, Coal::Kernel::Arg::Int32, Coal::Kernel::Arg::Int64, Coal::Kernel::Arg::Int8, Coal::Kernel::Arg::Invalid, Coal::Kernel::DeviceDependent::kernel, Coal::Kernel::Arg::Local, Coal::Kernel::DeviceDependent::module, p_args, p_device_dependent, p_has_locals, p_name, Coal::Object::p_type, and Coal::Kernel::Arg::Private.
Referenced by Coal::Program::createKernel().
| const Kernel::Arg & Kernel::arg | ( | unsigned int | index | ) | const |
Arg at the given index
Definition at line 303 of file kernel.cpp.
References p_args.
Referenced by Coal::CPUKernelWorkGroup::callArgs(), Coal::CPUKernel::callFunction(), Coal::KernelEvent::KernelEvent(), and setArg().
| bool Kernel::argsSpecified | ( | ) | const |
true if all the arguments have been set through setArg()
Definition at line 308 of file kernel.cpp.
References p_args.
Referenced by Coal::KernelEvent::KernelEvent().
| const Kernel::DeviceDependent & Kernel::deviceDependent | ( | DeviceInterface * | device | ) | const [private] |
Definition at line 74 of file kernel.cpp.
References Coal::Kernel::DeviceDependent::device, null_dep, and p_device_dependent.
Referenced by deviceDependentKernel(), function(), and workGroupInfo().
| Kernel::DeviceDependent & Kernel::deviceDependent | ( | DeviceInterface * | device | ) | [private] |
Definition at line 87 of file kernel.cpp.
References Coal::Kernel::DeviceDependent::device, null_dep, and p_device_dependent.
| DeviceKernel * Kernel::deviceDependentKernel | ( | DeviceInterface * | device | ) | const |
Coal::DeviceKernel for the specified device
Definition at line 324 of file kernel.cpp.
References deviceDependent(), and Coal::Kernel::DeviceDependent::kernel.
Referenced by Coal::KernelEvent::KernelEvent().
| llvm::Function * Kernel::function | ( | DeviceInterface * | device | ) | const |
Get the LLVM function for a specified device.
| device | the device for which a LLVM function is needed |
device Definition at line 226 of file kernel.cpp.
References deviceDependent(), and Coal::Kernel::DeviceDependent::function.
Referenced by addFunction().
| bool Kernel::hasLocals | ( | ) | const |
true if one or more argument is in file Arg::Local
Definition at line 319 of file kernel.cpp.
References p_has_locals.
Referenced by Coal::CPUKernelWorkGroup::callArgs(), and Coal::CPUKernelWorkGroup::run().
| cl_int Kernel::info | ( | cl_kernel_info | param_name, |
| size_t | param_value_size, | ||
| void * | param_value, | ||
| size_t * | param_value_size_ret | ||
| ) | const |
Get information about this kernel.
This function is used to retrieve information about an object. Sometimes, the size of the data retrieved is unknown (for example, a string). The application can call this function twice, the first time to get the size, then it allocates a buffer, and finally get the data.
const char *string = 0; size_t len; object->info(FOO_PROPERTY_STRING, 0, 0, &len); string = std::malloc(len); object->info(FOO_PROPERTY_STRING, len, string, 0);
| param_name | Name of the property to retrieve |
| param_value_size | Size of the application-allocated buffer in which to put the value. |
| param_value | Pointer to an application-allocated buffer where the property data will be stored. Ignored if NULL. |
| param_value_size_ret | Size of the value retrieved, ignored if NULL. |
Definition at line 331 of file kernel.cpp.
References MEM_ASSIGN, p_args, p_name, Coal::Object::parent(), Coal::Object::references(), and SIMPLE_ASSIGN.
Referenced by Coal::KernelEvent::KernelEvent().
| unsigned int Kernel::numArgs | ( | ) | const |
Number of arguments of this kernel.
Definition at line 298 of file kernel.cpp.
References p_args.
Referenced by Coal::CPUKernelWorkGroup::callArgs(), and Coal::KernelEvent::KernelEvent().
| cl_int Kernel::setArg | ( | cl_uint | index, |
| size_t | size, | ||
| const void * | value | ||
| ) |
Set the value of an argument.
See the constructor's documentation for a note on the Coal::Sampler objects
| index | index of the argument |
| size | size of the value being stored in the argument, must match Arg::valueSize() * Arg::vecDim() |
| value | pointer to the data that will be copied in the argument |
CL_SUCCESS if success, an error code otherwise Definition at line 233 of file kernel.cpp.
References Coal::Kernel::Arg::alloc(), arg(), Coal::Kernel::Arg::Buffer, Coal::Kernel::Arg::file(), Coal::Kernel::Arg::Image2D, Coal::Kernel::Arg::Image3D, Coal::Object::isA(), Coal::Kernel::Arg::kind(), Coal::Kernel::Arg::loadData(), Coal::Kernel::Arg::Local, p_args, Coal::Kernel::Arg::refineKind(), Coal::Kernel::Arg::Sampler, Coal::Kernel::Arg::setAllocAtKernelRuntime(), Coal::Object::T_Sampler, and Coal::Kernel::Arg::valueSize().
| cl_int Kernel::workGroupInfo | ( | DeviceInterface * | device, |
| cl_kernel_work_group_info | param_name, | ||
| size_t | param_value_size, | ||
| void * | param_value, | ||
| size_t * | param_value_size_ret | ||
| ) | const |
Get performance hints and device-specific data about this kernel.
This function is used to retrieve information about an object. Sometimes, the size of the data retrieved is unknown (for example, a string). The application can call this function twice, the first time to get the size, then it allocates a buffer, and finally get the data.
const char *string = 0; size_t len; object->info(FOO_PROPERTY_STRING, 0, 0, &len); string = std::malloc(len); object->info(FOO_PROPERTY_STRING, len, string, 0);
| param_name | Name of the property to retrieve |
| param_value_size | Size of the application-allocated buffer in which to put the value. |
| param_value | Pointer to an application-allocated buffer where the property data will be stored. Ignored if NULL. |
| param_value_size_ret | Size of the value retrieved, ignored if NULL. |
| device | Coal::DeviceInterface on which the kernel will be run |
Definition at line 383 of file kernel.cpp.
References deviceDependent(), Coal::Kernel::DeviceDependent::kernel, Coal::DeviceKernel::localMemSize(), Coal::DeviceKernel::preferredWorkGroupSizeMultiple(), Coal::DeviceKernel::privateMemSize(), SIMPLE_ASSIGN, and Coal::DeviceKernel::workGroupSize().
DeviceDependent Coal::Kernel::null_dep [private] |
Definition at line 295 of file kernel.h.
Referenced by deviceDependent(), and Kernel().
std::vector<Arg> Coal::Kernel::p_args [private] |
Definition at line 294 of file kernel.h.
Referenced by addFunction(), arg(), argsSpecified(), info(), numArgs(), and setArg().
std::vector<DeviceDependent> Coal::Kernel::p_device_dependent [private] |
Definition at line 293 of file kernel.h.
Referenced by addFunction(), deviceDependent(), and ~Kernel().
bool Coal::Kernel::p_has_locals [private] |
Definition at line 283 of file kernel.h.
Referenced by addFunction(), and hasLocals().
std::string Coal::Kernel::p_name [private] |
Definition at line 282 of file kernel.h.
Referenced by addFunction(), and info().
1.7.3