Skip to Content

oclSimpleKernel {OpenCL}

Create and compile OpenCL kernel code.
Package: 
OpenCL
Version: 
0.1-3

Description

oclSimpleKernel creates a kernel object by compiling the supplied code. The kernel can them be used in oclRun.

Usage

oclSimpleKernel(device, name, code, precision = c("single", "double", "best"))

Arguments

device
Device (element of the list returned by oclDevices()) to compile the kernel on.
name
Name of the kernel function - must match the name used in the supplied code.
code
character vector containg the code. The code will be concatenated (as-is, no newlines are added!) by the engine.
precision
precision of all floating-point arguments in the kernel. Note that R uses only double-precision floating point representation, so single-precision computation requires temporary conversion of all input and output values and thus has significant overhead. However, not all devices support double-precision computation. If "best" is used then the kernel code is expected to use single-precision but it will be automatically augmented to double-precision (by replacing words "float" with "double" in the code and adding the cl_khr_fp64 pragma) if supported by the device.

Details

oclSimpleKernel creates a new OpenCL context, then creates and builds the program specified by code and finally creates a kernel from the program.

The kernel built by this function is simple in that it can have exactly one vector output and arbitrarily many inputs. The first argument of the kernel must be __global double* for the output and the second argument must be const int for the length of the output vector. All additional arguments are optional. See oclRun for an example of a simple kernel.

Note that building a kernel can take substantial amount of time (depending on the OpenCL implementation) so it is generally a good idea to compile a kernel once and re-use it many times.

Values

Kernel object that can be used by oclRun.

See Also

oclDevices, oclRun

Author(s)

Simon Urbanek

Documentation reproduced from package OpenCL, version 0.1-3. License: BSD