Profiling a program

Profiling an application involves multiple steps from setting up the hardware in Xilinx® Platform Studio (XPS), setting up the software platform and application, and running the application. These steps are described in detail below.

Setting up the hardware

To profile a software application, you must ensure that interrupts are raised periodically to sample the program counter (PC) value. To do this, you must program a timer and use the timer interrupt handler to collect and store the PC. The profile interrupt handler requires full access to the timer, so a separate timer that is not used by the application itself must be available in the system.

Xilinx profiling libraries that provide the profile interrupt handler support the xps_timer core. When profiling on PowerPC® processors, the internal Programmable Interrupt Timer (PIT) can also be used. Either one of these timers should be available for exclusive use by the profile libraries.

The timer interrupt signal is connected directly to the processor, or it is connected to the processor through an interrupt controller. Look at the hardware design report (double click on the Hardware Platform Specification XML file in the Project Explorer to open its viewer and click on the hardware design report link), to check if the connectivity exists in the system.

Setting up the board support package

  1. Select the Board Support Package (BSP) of the software application in the Project Explorer View, then right-click and select Board Support Package Settings (or select Xilinx Tools > Board Support Package Settings).
  2. Click on the OS name, for example standalone, to configure its parameters, set the enable_sw_intrusive_profiling field to true and select the timer for use by the profile libraries.
  3. The BSP should be compiled with the -pg compiler option. To perform this step, click on the drivers item and select the cpu driver. Add the -pg flag to the extra_compiler_flags option.
  4. Click OK.

Setting up the software application

  1. Modify the software application code to enable interrupts. If there is an interrupt controller present in the system with multiple interrupt sources, you must enable interrupts in the processor and the interrupt controller to allow interrupts from the profile timer to reach the processor. Example code is shown below:

    /* enable interrupt controller */

    /* service all interrupts */

    /* enable the profile timer interrupt */

    /* enable interrupts in the processor */

  2. If the profiling timer is the only entity that connects to the input of interrupt controller or directly to the processor, the tool sets up the interrupt for you automatically, and no change is required in the application code.
  3. Right-click the software application and select C/C++ Settings (or Properties > C/C++ Build > Settings). Select gcc compiler > Profiling and enable profiling by selecting Enable Profiling (-pg).
  4. Click OK.

Creating a profile run configuration

To profile an application, you must create a configuration that captures the settings for profiling the application. Once the configuration has been created, it can be used to again debug the application.

  1. In the C/C++ Projects View, select the application to debug.
  2. Select Run > Run.
  3. In the Run Configurations dialog box, expand Xilinx C/C++ ELF.
  4. Click New. The name of the new project is displayed in the Configurations box. The default name is the name of the project.
  5. Make sure the ELF file generated using profile configuration is selected in the C/C++ Application field.
  6. In the Profiler tab, do the following:
    1. Click to select the Enable Profiling check box.
    2. Specify the Scratch Memory Address to Collect Profile Data to use for profiling in hex. This is a valid system memory address that is not used by the software application.
    3. Use the defaults for the Sampling Frequency and Histogram Bin Size values.
  7. Use the default settings for the other tabs and click Run.

Profiling the application

When the application finishes running (reaches exit), or when the stop button is pressed to stop the program, SDK downloads the profile data and stores it in a file named gmon.out. To view the profile results, double click on the gmon.out file associated with the application in the Project Explorer view. The profiling view is opened at the bottom of the SDK window.

For more information on interpreting the profile data in the profiler perspective, refer to Xilinx Profiling view

Related concepts
Profile overview
Profile configuration
Xilinx Profiling view

Related tasks
Configuring a board support package (SDK)
Creating or editing a run/debug/profile configuration

Copyright © 1995-2010 Xilinx, Inc. All rights reserved.