Source Code Analysis

For better understanding of a performance problem, associate a hotspot with the source code and exact machine instruction(s) that caused this hotspot.

Prerequisites

Intel® VTune™ Amplifier provides accurate source analysis if your code is compiled with the debug information and debug information is written correctly in the binary file (for Linux* targets) or debug information file/symbol file (for Windows* targets).

Access Source View

To open the source/assembly code of a specific item, either double-click the selected item in the grid view/Call Stack/Timeline pane, or select the View Source option from the context menu:

Depending on the route you used to access the Source view, the data representation on the panes may slightly differ:

  • If you access the Source view by clicking a function in the grid, the VTune Amplifier opens the source at the hottest (with the highest value of the metric selected for hotspot navigation) line of this function in the Source/Assembly pane.

  • When you click a call stack function, the VTune Amplifier opens the source highlighting the call site (location where a function call is made) at the top of the call stack. The call site is marked with the yellow arrow .

  • If you click a wait in the Timeline pane, the VTune Amplifier opens a wait function highlighting the waiting call site. If you double-click a transition (for Threading data), it highlights the signaling call site.

Analyze Code

The Source/Assembly window opens in a separate tab:

Source View

Source/Assembly toggle buttons. By default, depending on the symbol information availability, the VTune Amplifier opens one of the panes: Source or Assembly. But you can use the toggle Source and Assembly buttons on the toolbar to manage the view and enable both of them if required/possible.

The content displayed on the Source and Assembly panes is correlated. When you select an element on one pane, another pane scrolls to the corresponding elements and highlights them.

Note

  • One source code line may have one or more related assembly instructions while one instruction has only one related code line.

  • Synchronization is possible only if the debug line information is available for the selected function.

Hotspot navigation buttons. Typically, the VTune Amplifier opens the source code highlighting the most performance critical code line based on the key metric set up for this analysis. To go further and freely navigate between code lines that have the highest metric value (hotspots), use these buttons toolbar:

- Go to the code line that has the maximal metric value.

- Go to the previous (by metric value) hotspot line.

- Go to the next (by metric value) hotspot line.

- Go to the code line that has the minimal metric value.

The Source pane shows your code written on a high-level programming language, for example, C, C++, or Fortran. The Source pane opens if the symbol information for the selected function is available.

Hotspot navigation metric column. By default, the source view navigation is based on the key analysis metric like the CPU Time for the Hotspots analysis. Such a metric column is highlighted. To change the hotspot navigation metric, right-click the required column and select Use for Hotspot Navigation command from the context menu.

The Assembly pane displays disassembled code. This code shows the exact order of the assembly instructions executed by the processor. Instructions on the Assembly pane are grouped into basic blocks. To get help on a particular instruction, select it in the grid, right-click and choose Instruction Reference from the context menu.

For better navigation in the Assembly pane, you may select one of the available granularity levels in the Assembly grouping drop-down menu: Address, Basic Block/Address, or Function Range/Basic Block/Address. VTune Amplifier updates the Assembly view grouping the instructions into collapsible nodes according to the selected hierarchy.

If there is no correct debug information, or symbol file is unavailable, the assembly data may be incorrect. In this case, the VTune Amplifier uses heuristics to define function boundaries in the binary module.

Heat map markers. Use the blue markers to the right of the vertical scroll bar to quickly identify the hotspot lines (based on the hotspot navigation metric). To view a hotspot, move the scroll bar slider to the marker. The bright blue marker () indicates a hot line for the function you drilled down into. Light blue markers () indicate hot lines for other functions.

Edit Source

When tuning your target, you may need to modify the source code. VTune Amplifier enables you to open the source files for editing directly from the Source/Assembly window.

To launch the source editor:

  1. In the Source pane, select a line you want to edit.

  2. Right-click the line and select Edit Source from the context menu, or click the Open Source File EditorOpen editor button on the Source/Assembly toolbar.

    Your source code opens in the code editor set in your system as default. For example, on Linux the code editor is defined in the EDITOR environment variable (for example, vi) or VISUAL environment variables (for example, gedit, emacs). Depending on the editor application, the code may open exactly on the selected line.

After editing your code, rebuild your target and re-run the VTune Amplifier analysis on the modified version to compare the performance results before and after optimization.

Note

The Source/Assembly analysis is not supported for the source code using the #line directive.

For more complete information about compiler optimizations, see our Optimization Notice.
Select sticky button color: 
Orange (only for download buttons)