Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 4. Kernel programming: data type... > Introducing kernel coding

4.1. Introducing kernel coding

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.

Listing 4.1. A basic kernel: hello_kernel.cl

__kernel void hello_kernel(__global char16 *msg) {

   *msg = (char16)('H', 'e', 'l', 'l', 'o', ' ',
      'k', 'e', 'r', 'n', 'e', 'l', '!', '!', '!', '\0');
}


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint