Achieving Optimal Performance from C/C++ Source Code
#pragma optimize_{off|for_speed|for_space|as_cmd_line}
The
optimize_
a function-by-function basis. In particular, it may be useful to optimize
functions that are rarely called (for example, error handling code) for
space (using
#pragma optimize_for_space
performance should be compiled for maximum speed
(
#pragma optimize_for_speed
debugging specific functions without increasing the size or decreasing the
performance of the overall application unnecessarily.
For more information, refer to
page
1-125.
Loop Optimization Pragmas
Many pragmas are targeted towards helping to produce optimal code for
inner loops. These are the
#pragma loop_count
The
loop_count
about a loop's iteration count. The compiler is able to make more reliable
decisions about the optimization strategy for a loop if it knows the itera-
tion count range. If you know that the loop count is always a multiple of
some constant, this can also be useful as it allows a loop to be partially
unrolled or vectorized without the need for conditionally-executed itera-
tions. Knowledge of the minimum trip count may allow the compiler to
omit the guards that are usually required after software pipelining. Any of
the parameters of the pragma that are unknown may be left blank.
An example of the use of the
#pragma loop_count(/*minimum*/ 40, /*maximum*/ 100, /*modulo*/ 4)
for (i=0; i<n; i++)
a[i] = b[i];
VisualDSP++ 3.5 C/C++ Compiler and Library Manual
for ADSP-219x DSPs
pragma may be used to change the optimization setting on
). The
"General Optimization Pragmas" on
loop_count
pragma enables the programmer to inform the compiler
loop_count
), whereas functions critical to
#pragma optimize_off
and
pragmas.
no_alias
pragma might be:
is useful for
2-35
Need help?
Do you have a question about the VISUALDSP++ 3.5 and is the answer not in the manual?
Questions and answers