Learn R Programming

OpenCL (version 0.2-10)

oclSimpleKernel: Create and compile OpenCL kernel code.

Description

Creates a kernel object by compiling the supplied code. The kernel can then be used in oclRun.

Usage

oclSimpleKernel(context, name, code,
    output.mode = c("numeric", "single", "double", "integer"))

Value

Kernel object that can be used by oclRun.

Arguments

context

Context (as created by oclContext) to compile the kernel in.

name

Name of the kernel function - must match the name used in the supplied code.

code

Character vector containing the code. The code will be concatenated (as-is, no newlines are added!) by the engine.

output.mode

Mode of the output argument of the kernel, as in clBuffer. This can be one of "single", "double", "integer", or "numeric". The default value "numeric" maps to the default precision of the context.

The kernel code may use a type numeric that is typedef'd to the given precision, i.e. either float or double. The OpenCL extension cl_khr_fp64 will be enabled automatically in the second case, so you don't have to add the pragma yourself.

Author

Simon Urbanek, Aaron Puchert

Details

oclSimpleKernel builds the program specified by code and 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* or __global float* for the output and the second argument must be const unsigned int for the length of the output vector. Additional numeric scalar arguments are assumed to have the same mode as the output, i.e. if the output shall have "double" precision, then numeric scalar arguments are assumed to be double values, similarly for single-precision. 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

oclContext, oclRun