concept sampler in category opencl

appears as: samplers, sampler, The sampler, samplers
OpenCL in Action: How to Accelerate Graphics and Computation

This is an excerpt from Manning's book OpenCL in Action: How to Accelerate Graphics and Computation.

Chapter 4 discusses kernel arguments in greater detail and explains why you might set an argument’s data to NULL. Chapter 6 discusses samplers and their usage in image processing. This section is devoted to memory objects, which serve as standard packages for transferring data between a host and device.

Thankfully, OpenCL provides an easier way to work with samplers. With a single statement in the kernel, you can create a sampler_t structure and set its properties. This makes it unnecessary to call clSetKernelArg. This statement takes the following form:

const sampler_t sampler_name = sampler_properties

The sampler_properties expression configures the properties of the sampler, which tell the kernel how to read data from an image object. The names of these properties are similar to the parameters of clCreateSampler. On the kernel, sampler properties are specified with the following values:

6.1. Image objects and samplers

When it comes to processing images in OpenCL, the two primary data structures are image objects and samplers. Image objects serve as the storage mechanism that host applications use to transfer pixel data to and from a device. When the device receives the image data, samplers tell it how to read color values.

To keep things interesting, OpenCL gives different names to these structures depending on whether they’re on the host or the device. On the host, image objects are represented by cl_mem structures, and samplers are represented by cl_sampler structures. On the device, image objects are image2d_t or image3d_t structures, and samplers are sampler_t structures. This section discusses each of these data types and how they’re processed on the host and device.