Learn R Programming

OpenCL (version 0.1-2)

oclSimpleKernel: Create and compile OpenCL kernel code.

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"))

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. 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. Ho

Value

  • Kernel object that can be used by oclRun.

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.

See Also

oclDevices, oclRun