Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Chapter 2 explained how host applications send kernels to devices, and chapter 3 explained how to set arguments for kernels. Now, at long last, we’re ready to look at an actual kernel. The following listing presents an OpenCL equivalent for the venerable Hello World! function so common in C programming literature.
__kernel void hello_kernel(__global char16 *msg) {
*msg = (char16)('H', 'e', 'l', 'l', 'o', ' ',
'k', 'e', 'r', 'n', 'e', 'l', '!', '!', '!', '\0');
} |