Chapter 3. Host programming: data transfer and partitioning

 

This chapter covers

  • Creating memory objects to serve as kernel arguments
  • Commands that transfer data between the host and a device
  • Partitioning kernel execution using work-items and work-groups

The preceding chapter explained a great deal about host applications, from accessing platforms to creating kernels. But to do their jobs, devices need more than just kernels—they need data. If you want a device to perform a nontrivial computing task, you have to provide at least three pieces of information: the instructions to be executed, a buffer containing data to be processed, and a buffer where processed data should be stored.

In regular C/C++ programming, this isn’t a big deal. Just set suitable input and output parameters in a function call. But when you’re sending functions to another processor, this becomes more complicated. The first part of this chapter is devoted to explaining how to set arguments for OpenCL kernel functions.

After you’ve assigned data to a kernel, you may want to tell the target devices how to partition the data to improve performance. Different devices have different memory sizes and processing characteristics, so it’s a good idea to subdivide the data to take best advantage of the target architecture. This topic is discussed in the second part of this chapter.

3.1. Setting kernel arguments

3.2. Buffer objects

3.3. Image objects

3.4. Obtaining information about buffer objects

3.5. Memory object transfer commands

3.6. Data partitioning

3.7. Summary

sitemap