Instrumentation with Avrora
Avrora provides a basic set of command line options that can be used to collect
profiling information about programs as they are executed by the simulator. The
simulator core has a simple but powerful mechanism called a monitor that allows
users to add arbitrary program
instrumentation to the simulation.
Avrora also comes with a built-in set of monitors
that you can use to observe your program's execution.
Profiling Monitors in Avrora
Avrora provides a base set of monitors for the purpose of profiling your
program. These can be useful to analyze your program's execution patterns,
resource usage, etc.
The "profile" Monitor
The simplest but most detailed profiling monitor provided is the
profile monitor. This monitor records
the number of times each instruction in the program is executed and generates
a report when the program exits. It does this by inserting a
probe to each instruction in the
program that records the execution count and the number of cycles consumed.
It also has a number of options that generate
reports in different formats. Let's take a look at an example execution
of the profile monitor:
% avrora -monitors=profile simple.od
Avrora [Beta 1.6.0] - (c) 2003-2005 UCLA Compilers Group
This simulator and analysis tool is provided with absolutely no warranty,
either expressed or implied. It is provided to you with the hope that it be
useful for evaluation of and experimentation with microcontroller and sensor
network programs. For more information about the license that this software is
provided to you under, specify the "license" option.
Loading simple.od...[OK: 0.888 seconds]
=={ Simulation events }=======================================================
Node Time Event
------------------------------------------------------------------------------
==============================================================================
Simulated time: 166 cycles
Time for simulation: 0.461 seconds
Total throughput: 3.6008676E-4 mhz
=={ Monitors for node 0 }=====================================================
=={ Profiling results }=======================================================
Address Count Run Cycles Cumulative
------------------------------------------------------------------------------
0x0000: 1 3 = 1.8072 %
0x0004-0x0088: 0 x34
0x008C-0x00A6: 1 x14 15 = 9.0361 %
0x00A8-0x00AA: 2 x2 10 = 6.0240 %
0x00AC-0x00B0: 3 x3 11 = 6.6265 %
0x00B2-0x00B8: 1 x4 5 = 3.0120 %
0x00BA: 0
0x00BC-0x00C2: 1 x4 6 = 3.6144 %
0x00C6: 0
0x00CA-0x00D4: 1 x6 6 = 3.6144 %
0x00D6-0x00E0: 5 x4 46 = 27.7108 %
0x00E2: 4 8 = 4.8192 %
0x00E4: 1 1 = 0.6024 %
0x00E6-0x00EC: 0 x4
0x00F0-0x00FC: 5 x6 55 = 33.1325 %
0x00FE-0x0102: 0 x3
% _
|
As you can see, the profile monitor will generate a report that reports
the number of times executed and total cycles consumed by each instruction
in the program, collecting together long runs of instructions with the
same count. It also supports the -instr-classes
option that report on the dynamic count of each type of instruction
executed.
% avrora -monitors=profile -instr-classes simple.od
Avrora [Beta 1.6.0] - (c) 2003-2005 UCLA Compilers Group
This simulator and analysis tool is provided with absolutely no warranty,
either expressed or implied. It is provided to you with the hope that it be
useful for evaluation of and experimentation with microcontroller and sensor
network programs. For more information about the license that this software is
provided to you under, specify the "license" option.
Loading simple.od...[OK: 0.871 seconds]
=={ Simulation events }=======================================================
Node Time Event
------------------------------------------------------------------------------
==============================================================================
Simulated time: 166 cycles
Time for simulation: 0.469 seconds
Total throughput: 3.5394458E-4 mhz
=={ Monitors for node 0 }=====================================================
=={ Profiling results }=======================================================
Address Count Run Cycles Cumulative
------------------------------------------------------------------------------
0x0000: 1 3 = 1.8072 %
0x0004-0x0088: 0 x34
0x008C-0x00A6: 1 x14 15 = 9.0361 %
0x00A8-0x00AA: 2 x2 10 = 6.0240 %
0x00AC-0x00B0: 3 x3 11 = 6.6265 %
0x00B2-0x00B8: 1 x4 5 = 3.0120 %
0x00BA: 0
0x00BC-0x00C2: 1 x4 6 = 3.6144 %
0x00C6: 0
0x00CA-0x00D4: 1 x6 6 = 3.6144 %
0x00D6-0x00E0: 5 x4 46 = 27.7108 %
0x00E2: 4 8 = 4.8192 %
0x00E4: 1 1 = 0.6024 %
0x00E6-0x00EC: 0 x4
0x00F0-0x00FC: 5 x6 55 = 33.1325 %
0x00FE-0x0102: 0 x3
=={ Profiling Results by Instruction Type }===================================
Instruction Count Cycles Percent
------------------------------------------------------------------------------
call: 5 20 12.0481 %
ret: 5 20 12.0481 %
ldi: 20 20 12.0481 %
rjmp: 6 12 7.2289 %
lds: 5 10 6.0240 %
sts: 5 10 6.0240 %
sbiw: 5 10 6.0240 %
muls: 5 10 6.0240 %
elpmpi: 2 6 3.6144 %
sbrs: 5 6 3.6144 %
eor: 6 6 3.6144 %
out: 6 6 3.6144 %
brne: 4 6 3.6144 %
jmp: 2 6 3.6144 %
movw: 5 5 3.0120 %
stpi: 2 4 2.4096 %
cpi: 4 4 2.4096 %
cpc: 4 4 2.4096 %
break: 1 1 0.6024 %
% _
|
The "calls" Monitor
Profiling a program at the instruction level can give very precise and detailed
results, but it may be time-consuming to sift through the details and match up
instruction ranges to functions in the original program. For this reason,
the simulator provides a calls monitor
that reports the call and interrupt behavior of the program as it executes.
% avrora -monitors=calls simple.od
Avrora [Beta 1.6.0] - (c) 2003-2005 UCLA Compilers Group
This simulator and analysis tool is provided with absolutely no warranty,
either expressed or implied. It is provided to you with the hope that it be
useful for evaluation of and experimentation with microcontroller and sensor
network programs. For more information about the license that this software is
provided to you under, specify the "license" option.
Loading simple.od...[OK: 0.883 seconds]
=={ Simulation events }=======================================================
Node Time Event
------------------------------------------------------------------------------
0 60 @ 0x00D6 --(CALL)-> foo
0 71 @ 0x00DA <-(RET)--
0 82 @ 0x00D6 --(CALL)-> foo
0 93 @ 0x00DA <-(RET)--
0 104 @ 0x00D6 --(CALL)-> foo
0 115 @ 0x00DA <-(RET)--
0 126 @ 0x00D6 --(CALL)-> foo
0 137 @ 0x00DA <-(RET)--
0 148 @ 0x00D6 --(CALL)-> foo
0 159 @ 0x00DA <-(RET)--
==============================================================================
Simulated time: 166 cycles
Time for simulation: 0.492 seconds
Total throughput: 3.3739838E-4 mhz
=={ Monitors for node 0 }=====================================================
Maximum stack depth: 1 frames
% _
|
The "trip-time" Monitor
Profiling a program for every instruction or every call in the program can
give very precise results, but can generate a large amount of information. Often
a profiling task may be as simple as determining the time between entering
one point of the program (such as an interrupt handler) and reaching another
point of the program (such as the end of the interrupt handler). The
trip-time monitor is provided for this
purpose. Here is an example of using it to determine the average running
time for a function in an example program:
% avrora -monitors=trip-time -pairs=foo:0xfc simple.od
Avrora [Beta 1.6.0] - (c) 2003-2005 UCLA Compilers Group
This simulator and analysis tool is provided with absolutely no warranty,
either expressed or implied. It is provided to you with the hope that it be
useful for evaluation of and experimentation with microcontroller and sensor
network programs. For more information about the license that this software is
provided to you under, specify the "license" option.
Loading simple.od...[OK: 0.877 seconds]
=={ Simulation events }=======================================================
Node Time Event
------------------------------------------------------------------------------
==============================================================================
Simulated time: 166 cycles
Time for simulation: 0.493 seconds
Total throughput: 3.36714E-4 mhz
=={ Monitors for node 0 }=====================================================
start end count avg std max min
------------------------------------------------------------------------------
0x00F0 0x00FC 5 7.0 0.0 7.0 7.0
% _
|
|
Note:
For this example, we need to know the addresses of the instructions corresponding
to the start and end of the foo() function in our
example. We can do this by using the label foo
at the beginning of the method in the assembly and
inspecting the assembly and looking for the
ret instruction at the end of the method.
|
The "interrupts" Monitor
Microcontroller programs often have to respond to interrupts that are generated by
external devices such as a serial controller or devices on the chip such as a timer.
Monitoring and profiling interrupts is easy with Avrora; it provides a special
instrumentation point for interrupts
that monitors can use to record statistics about interrupts. Avrora also provides
an interrupts monitor that allows the
user to observe and profile the interrupts and interrupt handlers of the program.
% avrora -monitors=interrupts simple.od
Avrora [Beta 1.6.0] - (c) 2003-2005 UCLA Compilers Group
This simulator and analysis tool is provided with absolutely no warranty,
either expressed or implied. It is provided to you with the hope that it be
useful for evaluation of and experimentation with microcontroller and sensor
network programs. For more information about the license that this software is
provided to you under, specify the "license" option.
Loading simple.od...[OK: 0.898 seconds]
=={ Simulation events }=======================================================
Node Time Event
------------------------------------------------------------------------------
==============================================================================
Simulated time: 166 cycles
Time for simulation: 0.478 seconds
Total throughput: 3.4728032E-4 mhz
=={ Monitors for node 0 }=====================================================
=={ Interrupt monitor results }===============================================
Num Name Invocations Separation Latency Wakeup
------------------------------------------------------------------------------
1 RESET 0
2 INT0 0
3 INT1 0
4 INT2 0
5 INT3 0
6 INT4 0
7 INT5 0
8 INT6 0
9 INT7 0
10 TIMER2 COMP 0
11 TIMER2 OVF 0
12 TIMER1 CAPT 0
13 TIMER1 COMPA 0
14 TIMER1 COMPB 0
15 TIMER1 OVF 0
16 TIMER0 COMP 0
17 TIMER0 OVF 0
18 SPI, STC 0
19 USART0, RX 0
20 USART0, UDRE 0
21 USART0, TX 0
22 ADC 0
23 EE READY 0
24 ANALOG COMP 0
25 TIMER1 COMPC 0
26 TIMER3 CAPT 0
27 TIMER3 COMPA 0
28 TIMER3 COMPB 0
29 TIMER3 COMPC 0
30 TIMER3 OVF 0
31 USART1, RX 0
32 USART1, UDRE 0
33 USART1, TX 0
34 TWI 0
35 SPM READY 0
% _
|
The "memory" Monitor
Sometimes the memory behavior of the program is of particular interest. For example,
does the program allocate pieces of memory that are not used at all? Is the stack
growing too large? For an architecture with a cache, it may be important to study
the locality of a program's access behavior. For this purpose, the
memory monitor allows the user to analyze
the memory behavior of their program and generate a report of which memory
locations are being accessed the most frequently.
% avrora -monitors=memory simple.od
Avrora [Beta 1.6.0] - (c) 2003-2005 UCLA Compilers Group
This simulator and analysis tool is provided with absolutely no warranty,
either expressed or implied. It is provided to you with the hope that it be
useful for evaluation of and experimentation with microcontroller and sensor
network programs. For more information about the license that this software is
provided to you under, specify the "license" option.
Loading simple.od...[OK: 0.886 seconds]
=={ Simulation events }=======================================================
Node Time Event
------------------------------------------------------------------------------
==============================================================================
Simulated time: 166 cycles
Time for simulation: 0.497 seconds
Total throughput: 3.3400403E-4 mhz
=={ Monitors for node 0 }=====================================================
=={ Memory profiling results }================================================
Address Reads Writes
------------------------------------------------------------------------------
0x0100: 0 0.0000 % 1 5.8823 %
0x0101: 5 33.3333 % 6 35.2941 %
0x0102: 0 0.0000 % 0 0.0000 %
. .
0x10FE: 5 33.3333 % 5 29.4117 %
0x10FF: 5 33.3333 % 5 29.4117 %
total : 15 100.0000 % 17 100.0000 %
% _
|
The "energy" Monitor
Many applications domains where microcontrollers are used have constraints
on the energy consumption of the design. For example, a sensor node that is
running on a battery that is expected to last for weeks or months should
conserve as much energy as possible by sleeping and turning off devices.
Avrora provides an energy monitor that
will monitor the energy consumption of the hardware devices as the program
executes and generate a report at the end of the simulation.
% avrora -monitors=energy simple.od
Avrora [Beta 1.6.0] - (c) 2003-2005 UCLA Compilers Group
This simulator and analysis tool is provided with absolutely no warranty,
either expressed or implied. It is provided to you with the hope that it be
useful for evaluation of and experimentation with microcontroller and sensor
network programs. For more information about the license that this software is
provided to you under, specify the "license" option.
Loading simple.od...[OK: 0.962 seconds]
=={ Simulation events }=======================================================
Node Time Event
------------------------------------------------------------------------------
==============================================================================
Simulated time: 166 cycles
Time for simulation: 0.463 seconds
Total throughput: 3.585313E-4 mhz
=={ Monitors for node 0 }=====================================================
Energy Consumption Component Breakdown:
Node lifetime: 166 cycles, 2.075E-5 seconds
CPU: 4.71027075E-7 Joule
Active: 4.71027075E-7 Joule, 166 cycles
Idle: 0.0 Joule, 0 cycles
RESERVED 1: 0.0 Joule, 0 cycles
ADC Noise Reduction: 0.0 Joule, 0 cycles
RESERVED 2: 0.0 Joule, 0 cycles
Power Down: 0.0 Joule, 0 cycles
Standby: 0.0 Joule, 0 cycles
Power Save: 0.0 Joule, 0 cycles
Extended Standby: 0.0 Joule, 0 cycles
% _
|
The "sleep" Monitor
Many microcontroller programs put the chip to sleep for long periods of time
to conserve energy. The microcontroller may have multiple different sleep modes
with different responsiveness and energy consumption characteristics. The
sleep monitor allows the user to track
the program's sleeping behavior and generate a report at the end of simulation.
% avrora -monitors=sleep simple.od
Avrora [Beta 1.6.0] - (c) 2003-2005 UCLA Compilers Group
This simulator and analysis tool is provided with absolutely no warranty,
either expressed or implied. It is provided to you with the hope that it be
useful for evaluation of and experimentation with microcontroller and sensor
network programs. For more information about the license that this software is
provided to you under, specify the "license" option.
Loading simple.od...[OK: 0.882 seconds]
=={ Simulation events }=======================================================
Node Time Event
------------------------------------------------------------------------------
==============================================================================
Simulated time: 166 cycles
Time for simulation: 0.491 seconds
Total throughput: 3.3808555E-4 mhz
=={ Monitors for node 0 }=====================================================
=={ Sleep Monitor Results }===================================================
State Cycles Percent
------------------------------------------------------------------------------
Active 166 100.0000 %
Idle 0 0.0000 %
RESERVED 1 0 0.0000 %
ADC Noise Reduction 0 0.0000 %
RESERVED 2 0 0.0000 %
Power Down 0 0.0000 %
Standby 0 0.0000 %
Power Save 0 0.0000 %
Extended Standby 0 0.0000 %
% _
|
[
Home |
Download |
Get Started |
Online CVS |
JavaDoc API ]
Copyright (c) 2004-2005, UCLA Compilers Group
The Avrora logo background is Copyright (c) 1996 Jan Curtis, used with permission.
|