Function Inlining - 2020.2 English

Vitis Unified Software Platform Documentation: Application Acceleration Development (UG1393)

Document ID
Release Date
2020.2 English

C code generally consists of several functions. By default, each function is compiled, and optimized separately by the Vitis compiler. A unique hardware module will be generated for the function body and reused as needed.

From a performance perspective, in general it is better to inline the function, or dissolve the function hierarchy. This helps Vitis compiler to perform optimization more globally across the function boundary. For example, if a function is called inside a pipelined loop, then inlining the function helps the compiler to do more aggressive optimization and results in a better pipeline performance of the loop (lower initiation interval or II number).

The following INLINE pragma placed inside the function body instruct the compiler to inline the function.
foo_sub (p, q) {
  #pragma HLS INLINE

However, if the function body is very big and called several times inside the main kernel function, then inlining the function may cause capacity issues due to consuming too many resources. In cases like that you might not inline such functions, and let the v++ compiler optimize the function separately in its local context.