Profiling Your Code
3-13
Optimizing C/C++ Code
3.3
Profiling Your Code
In large applications, it makes sense to optimize the most important sections
of code first. You can use the information generated by profiling options to get
started. You can use several different methods to profile your code. These
methods are described below.
3.3.1
Using the Standalone Simulator (load6x) to Profile
There are two methods to using the standalone simulator (load6x) for profiling.
-
If you are interested in just a profile of all of the functions in your applica-
tion, you can use the –g option in load6x.
-
If you are interested in just profiling the cycle count of one or two functions,
or if you are interested in a region of code inside a particular function, you
can use calls to the clock( ) function (supported by load6x) to time those
particular functions or regions of code.
3.3.1.1
Using the –g Option to Profile on load6x
Invoking load6x with the –g option runs the standalone simulator in profiling
mode. Source files must be compiled with the –mg profiling option for profiling
to work on the standalone simulator. The profile results are stored in a file
called by the same name as the .out file, but with the .vaa extension.
If you used the –mg profiling option when compiling and linking ”example.out”,
use the –g option to create a file in which you can view the profiling results. For
example, enter the following on your command line:
load6x –g example.out
Now, you can view the file ”example.vaa” to see the results of the profile ses-
sion created with the –mg option on the .out file.
Your new file, ”example.vaa” should have been created in the same directory
as the .out file. You can edit the .vaa file with a text editor. You should see some-
thing like this:
Program Name: example.out
Start Address: 00007980 main, at line 1, ”demo1.c”
Stop Address: 00007860 exit
Run Cycles: 3339
Profile Cycles: 3339
BP Hits: 11
*******************************************************
Area Name Count Inclusive Incl–Max
Exclusive Excl–Max
CF iir1( )
1
236
236
236
236
CF vec_mpy1( )
1
248
248
248
248
CF mac1( )
1
168
168
168
168
CF main( )
1
3333
3333
40
40