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 Vitis compiler.
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 might 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 Vitis compiler uses its own rules to inline or not inline a function. To directly control inlining functions, use the ALWAYS_INLINE or NOINLINE attributes.
By default, inlining is only performed on the next level of function hierarchy, not sub-functions.
Syntax
__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 ) {
...
}