Chapter 5. Kernel programming: operators and functions
This chapter covers
Chapter 4 discussed data types and emphasized the different types of vectors available. Vectors can dramatically improve an application’s performance by making it possible to operate on multiple values at once. But before you can use them in a practical application, you need to know what operators and functions are available to process them. The goal of this chapter is to explain these operators and functions, and to provide example code to demonstrate their usage.
Most of these operators and functions relate to mathematics, and the OpenCL working group has wisely kept to the naming conventions set by math.h. For example, you can call sqrt to compute the square root of a floating-point vector and pow to compute xy. But OpenCL also provides new functions like mad_sat and mad_hi, which make it possible to perform math operations quickly and accurately.