always_inline

Description

The always_inline attribute indicates that a function must be inlined. This attribute is a standard feature of GCC, and a standard feature of the SDx compilers.
TIP: The noinline attribute is also a standard feature of GCC, and is also supported by SDx compilers.

This attribute enables a compiler optimization to have a function inlined into the calling function. The inlined function is dissolved and no longer appears as a separate level of hierarchy in the RTL.

In some cases, inlining a function allows operations within the function to be shared and optimized more effectively with surrounding operations in the calling function. However, an inlined function can no longer be shared with other functions, so the logic may be duplicated between the inlined function and a separate instance of the function which can be more broadly shared. While this can improve performance, this will also increase the area required for implementing the RTL.

For OpenCL kernels, the SDX compiler uses its own rules to inline or not inline a function. To directly control inlining functions, you should use the always_inline or noinline attributes.

By default, inlining is only performed on the next level of function hierarchy, not sub-functions.

IMPORTANT!: When used with the xcl_dataflow attribute, the compiler will ignore the always_inline attribute and not inline the function.

Syntax

Place the attribute in the OpenCL source before the function definition to always have it inlined whenever the function is called.
__attribute__((always_inline))

Examples

This example adds the always_inline attribute to function foo:
__attribute__((always_inline))
  void foo ( a, b, c, d ) {
  ...
}
This example prevents the inlining of the function foo:
__attribute__((noinline))
  void foo ( a, b, c, d ) {
  ...
}

See Also