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 ...