Lesson 4: Program Level Optimization
2-24
Example 2–13. Profile Statistics
Location Count Average Total Maximum Minimum
lesson_c.c line 27 1 5020.0 5020 5020 5020
lesson_c.c line 36 1 60.0 60 60 60
lesson1_c.c line 37 1 60.0 60 60 60
lesson2_c.c line 39 1 60.0 60 60 60
lesson3_c.c line 44 1 60.0 60 60 60
lesson1_c.c line 27 1 12.0 12 12 12
lesson2_c.c line 29 1 12.0 12 12 12
lesson3_c.c line 35 1 12.0 12 12 12
This is quite a performance improvement. The compiler automatically extracts
and acts upon all the information that we passed in Lessons 1 to 3. Even the
original untouched tutor1 is 100% optimized by discounting memory depen-
dencies, unrolling, and performing packed data optimization.
Table 2–4. Status Update: Tutorial example lesson_c lesson1_c lesson2_c lesson3_c
Tutorial Example
Lesson_c
Lesson1_c
Lesson2_c
Lesson3_c
Potential pointer aliasing info (discussed in Les-
son 1)
p
p
p
Loop count info – minimum trip count (discussed
in Lesson 2)
p
p
Loop count info – max trip count factor (dis-
cussed in Lesson 2)
p
p
Alignment info – xptr & yptr aligned on a word
boundary (discussed in Lesson 3)
p
Cycles per iteration (discussed in Lesson 1–3)
10
2
1.5
1
Cycles per iteration with program level optimiza-
tion (discussed in Lesson 4)
1
1
1
1
This tutorial has shown you that a lot can be accomplished by both tuning your
C code and using program level optimization. Many different types of tuning
optimizations can be done in addition to what was presented here.
We recommend you use Appendix A, Feedback Solutions, when tuning your
code to get “how to” answers on all of your optimizing C questions. You can
also use the Feedback Solutions Appendix as a tool during development. We
believe this offers a significant advantage to TI customers and we plan on con-
tinuing to drive a more developer–friendly environment in our future releases.