O'Reilly logo

OpenCL Parallel Programming Development Cookbook by Raymond Tay

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using floating-point functions

So far, you have seen a couple of functions that takes argument as input or output single-precision or double-precision floating-point values. Given a floating-point value x, the OpenCL floating-point functions provide you with the capability to extract the mantissa and exponent from x via frexp(), decompose x via modf(), compute the next largest/smallest single-precision floating-point value via nextafter(), and others. Considering that there are so many useful floating-point functions, there are two functions which are important to understand because it's very common in OpenCL code. They are the mad() and fma() functions which is Multiply-Add and Fused Multiply-Add instruction respectively.

The Multiply-Add (MAD ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required