Tutorial by Examples

Lets build a kernel to generate a grayscale image. We will use image data which is defined using uints for each component and with order RGBA. __constant sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | C...
Lets walk through the most simple kernel there is and some variations of it __kernel void myKernel() { } A kernel which can be started from your main code is identified by the __kernel keyword. A Kernel function can only have return type void. __kernel void myKernel(float a, uint b, byte c) { ...
To properly work with the data each thread needs to know its position in the threadblock/global thread pool. This can be archieved with get_local_id($dim); get_global_id($dim); Those two functions return the position of the thread relative to the threadblock or all threads. get_working_dim(); ...
Each fundamental opencl type has a vector version. You can use the vector type by appending the number of desired components after the type. Supported number of components are 2,3,4,8 and 16. OpenCL 1.0 does not offer three components. You can initialize any vector using two ways: Provide a sing...
Lets look at a gamma correction kernel __constant sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_LINEAR; __kernel void Gamma(__read_only image2d_t input, __write_only image2d_t output, __c...

Page 1 of 1