Instrumentation with AvroraAvrora 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 AvroraAvrora 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" MonitorThe 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: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.
The "calls" MonitorProfiling 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.
The "trip-time" MonitorProfiling 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:
The "interrupts" MonitorMicrocontroller 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.
The "memory" MonitorSometimes 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.
The "energy" MonitorMany 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.
The "sleep" MonitorMany 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. |