..

program & kernel

这两个模块结合的相对紧密, 写到一块了。


program 定义

a kernel represents a single function to be executed on a device. In contrast, a program is a container of kernels.

创建流程

Program objects are created with one of the static create_with_* functions.

std::string source = "__kernel void foo(__global int *data) { }";

boost::compute::program foo_program =
    boost::compute::program::create_with_source(source, context);

// build the program
foo_program.build();

// create a kernel from the compiled program
boost::compute::kernel foo_kernel = foo_program.create_kernel("foo");

API

std::string build_log() const;
Returns the build log.

创建 kernel

After you’ve compiled and linked a program, you can package its functions into data structures called kernels. The advantage of using kernels is that they’re deployable— kernels can be dispatched to a command queue and sent to a device.

API

template<typename T> T get_info(cl_kernel_info info) const;
Returns information about the kernel.

See the documentation for clGetKernelInfo() for more information.

Nothing