#pragma unroll[(n)], #pragma unroll_completely
Instructs the compiler to unroll a loop by
is an optional value indicating the number of iterations to unroll.
If you do not specify a value for
, the compiler attempts to fully unroll
the loop. The compiler can only fully unroll loops where it can determine the number
#pragma unroll_completely will not
unroll a loop if the number of iterations is not known at compile time.
This pragma only has an effect with optimization level
-O2 and higher.
When compiling with
compiler automatically unrolls loops where it is beneficial to do so. This pragma
can be used to ask the compiler to unroll a loop that has not been unrolled
#pragma unroll[( can be used immediately before a
for loop, a
while loop, or a
This pragma is a request to the compiler to unroll a loop that has not been unrolled automatically. It does not guarantee that the loop is unrolled.