Chapter 4

Examples

Abstract

This chapter provides four complete OpenCL examples (both host code and kernels). The examples include OpenCL implementations of histogram, image rotation, and convolution, as well as a producer-consumer design executing on multiple devices. These algorithms illustrate features such as communication via local memory, atomic operations, images, samplers, and pipes.

Keywords

local memory

local atomics

global atomics

barriers

memory fences

images

samplers

C++ API

pipes

multiple devices

4.1 OpenCL Examples

This chapter discusses some basic OpenCL examples, which allow us to summarize our understanding of the specification discussed in Chapter 3. These examples demonstrate the programming steps needed to write complete ...

Get Heterogeneous Computing with OpenCL 2.0 now with O’Reilly online learning.

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