Chapter 2. HelloWorld: An OpenCL Example
In order to introduce you to OpenCL, we begin with a simple example program. This chapter demonstrates the code required to set up and execute a kernel on an OpenCL device. The example executes a simple kernel that adds the values stored in two arrays and saves the result in another. This chapter introduces the following concepts:
• Choosing an OpenCL platform and creating a context
• Enumerating devices and creating a command-queue
• Creating and building a program object
• Creating a kernel object and memory objects for kernel arguments
• Executing a kernel and reading its result
• Checking for errors in OpenCL
This chapter will go over the basics of each of these steps. Later in the book, we will fill ...
Get OpenCL Programming Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.