SIMD Math Library man pages

The SIMD Math Library contains a set of functions which extend the common mathematical functions to operate on vectors.

These functions are defined in the document SIMD Math Library Specification for Cell Broadband Engine Architecture, Version 1.0.

This book contains the SIMD Math Library man pages in printable form, including graphical images of the equations which cannot be rendered in man page format.

Overview

The traditional mathematical functions specified by standards such as ISO/IEC 9899:1999 (more commonly known as the "C99 standard") are defined in terms of scalar instructions and do not take advantage of the powerful Single Instruction, Multiple Data (SIMD) vector instructions provided by both the PPU and SPU instruction sets of the Cell BE architecture.

The SIMD Math library provides short vector versions of a subset of the traditional mathematical functions. (See the Mathematical Acceleration Subsystem (MASS) library for long vector versions.) These vector versions conform as closely as possible to the specifications set out by the scalar standards. However, fundamental differences between scalar architectures and the Cell BE architecture require some deviations, including the handling of rounding, error conditions, floating-point exceptions and special operands such as NaN and infinities.

The SIMD Math library is provided in the SDK as both a linkable library archive and as a set of inline function headers. The function names are differentiated from their scalar counterparts by appending a vector type suffix to the standard scalar function name. For example, the SIMD version of fabs() which acts on a vector float is called fabsf4(), and the version which acts on a vector double is called fabsd2(). Inline versions of functions are prefixed with an underscore character '_', so for example the inline version of fabsf4() is called _fabsf4().

Both the linkable and inline versions require the inclusion of the primary header file simdmath.h and must be linked with the libsimdmath.a library. In addition, the inline versions require inclusion of a distinct header file for each function used. For example, to use the inline function _fabsf4() the fabsf4.h header file must be included in addition to simdmath.h. Some classification functions also require definitions from the math.h header file.

The linkable library archive is more convenient to code as it only requires the inclusion of a single header file, but it produces slower, larger binaries due to the branching instructions necessary for function calls, and also due to limitations of the linker. The inline functions require extra header files to be included for each math function used, but produce faster and smaller (unless inlined multiple times) binaries, because the compiler is able to reduce branching and often achieves better dual-issue rates and optimization.

For the PPU the SIMD Math library header file simdmath.h is located in the /usr/include directory, with the inline headers located in the /usr/include/simdmath directory and the library libsimdmath.a located in the /usr/lib directory.

For the SPU the header file is located in the /usr/spu/include directory, with inline headers in the /usr/spu/include/simdmath directory and the library located in the /usr/spu/lib directory.

Organisation

The SIMD Math functions are grouped into sections as follows:

  1. Absolute value and sign functions

    (Remove or extract the signs from values.)

  2. Classification and comparison functions

    (Return boolean values from comparison or classification of elements.)

  3. Divide, multiply, modulus, remainder and reciprocal functions

    (Standard arithmetic operations.)

  4. Exponentiation, Root, and Logarithmic functions

    (Functions related to exponentiation or the inverse.)

  5. Gamma and Error functions

    (Probability functions.)

  6. Minimum and Maximum functions

    (Return the larger, smaller or absolute difference between elements.)

  7. Rounding and next functions

    (Convert floating point values to integers.)

  8. Trigonometric functions

    (sin, cos, tan and their inverses.)

  9. Hyperbolic functions

    (sinh, cosh, tanh and their inverses.)