always_inline
Description
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.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.
xcl_dataflow
attribute, the compiler will ignore the always_inline
attribute and not inline the function.Syntax
__attribute__((always_inline))
Examples
always_inline
attribute to function foo
:__attribute__((always_inline))
void foo ( a, b, c, d ) {
...
}
foo
:__attribute__((noinline))
void foo ( a, b, c, d ) {
...
}
See Also
- https://gcc.gnu.org
- SDAccel Environment Profiling and Optimization Guide (UG1207)