Lesson 4: Program Level Optimization
2-23
Compiler Optimization Tutorial
2.5
Lesson 4: Program Level Optimization
In Lesson 3, you learned how to pass information to the compiler. This in-
creased the amount of information visible to the compiler from the local scope
of each function.
Q Is this necessary in all cases?
A The answer is no, not in all cases. First, if this information already resides
locally inside the function, the compiler has visibility here and restrict and
MUST_ITERATE statements are not usually necessary. For example, if xptr
and yptr are declared as local arrays, the compiler does not assume a depen-
dency with w_sum. If the loop count is defined in the function or if the loop sim-
ply described from one to forty, the MUST_ITERATE pragma is not necessary.
Secondly, even if this type of information is not declared locally, the compiler
can still have access to it in an automated way by giving it a program level view.
This module discusses how to do that.
The ’C6000 compiler provides two valuable switches, which enable program
level optimization: –pm and –op2. When these two options are used together,
the compiler can automatically extract all of the information we passed in the
previous examples. To tell the compiler to use program level optimization, you
need to turn on –pm and –op2.
Enable program level optimization
1) From the Project menu, choose Options, and click on the Basic category.
2) Select No External Refs in the Program Level Optimization drop-down
box. This adds –pm and –op2 to the command line.
View profile statistics
1) Clear the Profile Statistics window by right clicking on it and selecting Clear
All.
2) From the Project menu, choose Rebuild All.
3) From the File menu, choose Reload Program.
4) From the Debug menu, chose Run.
The new profile statistics should appear in the Profile Statistics window, as
in Example 2–13.