Chapter 4. Kernel programming: data types and device memory


This chapter covers
  • Introducing a simple OpenCL kernel
  • Using OpenCL’s scalar and vector data types
  • Understanding the OpenCL device model


In this chapter, we’re going to put aside the scaffolding that creates and deploys kernels, and start coding the kernels themselves. We’ll examine the data types available in OpenCL kernels, and that means we’ll finally get to discuss vectors. When you process data with vectors, you put aside boring, decades-old data types like char, float, and int, and use new, exciting data types like char16, int3, and float4. Now we’re cooking!

I didn’t learn about vector programming until after I left college, but I’ve always enjoyed it since. It doesn’t ...

Get OpenCL in Action: How to Accelerate Graphics and Computation now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.