oclContext: Create an OpenCL context for a given device.

View source: R/ocl.R

oclContextR Documentation

Create an OpenCL context for a given device.

Description

OpenCL contexts host kernels and buffers for the device they are hosted on. They also have an attached command queue, which allows out-of-order execution of all operations. Once you have a context, you can create a kernel in the context with oclSimpleKernel.

Usage

oclContext(device = "default", precision = c("best", "single", "double"))

Arguments

device

Device object as obtained from oclDevices or a type as in oclDevices. In this case, a suitable device of the given type will be selected automatically.

precision

Default precision of the context. This is the precision that will be chosen by default for numeric buffers and kernels with numeric output mode.

Value

An OpenCL context.

Author(s)

Aaron Puchert

See Also

oclDevices, oclSimpleKernel

Examples

library(OpenCL)
cat("== Platforms:\n")
(platforms <- oclPlatforms())
if (length(platforms)) {
    cat("== Devices:\n")
    ## pick the first platform
    print(devices <- oclDevices(platforms[[1]]))
    if (length(devices)) {
        cat("== Context:\n")
        ## pick the first device
        print(ctx <- oclContext(devices[[1]]))
    }
    cat("== Default context:\n")
    ## Note that context can find device on its own
    ## (may be different from above if you have multiple devices)
    print(c2 <- oclContext())
}

s-u/OpenCL documentation built on March 15, 2024, 6:44 a.m.