Finding Hotspots in Your Code with the Intel VTune Command-Line Interface

Article ID: 506
Last updated: 31 Dec, 2025

The Intel VTune Profiler (renamed from Amplifier starting with 2020.0 version) is an analysis and tuning tool that provides predefined analysis configurations to address various performance questions. Among them, the hotspots analysis type can help you to identify the most time-consuming parts of your code and provide call stack information down to the source lines.

The hotspots analysis type allows two data collection methods: (1) user-mode sampling and tracing collection, and (2) hardware event-based sampling collection. Both methods are supported on all current Aitken and Electra Intel processor types: Broadwell, Skylake, and Cascade Lake.

Note: For the AMD Rome and Milan nodes, the user-mode sampling and tracing collection is supported but the hardware event-based sampling collection is not.

The instructions below apply to using the user-mode sampling and tracing collection type, with a fixed sampling interval of 10 ms.

Setting Up to Run a Hotspots Analysis

Complete these steps to prepare for profiling your code:

  1. Add the -g option to your usual set of compiler flags in order to generate a symbol table, which is used by VTune during analysis. Keep the same optimization level that you intend to run in production.
  2. For MPI applications, build the code with the latest version of MPT library, as it will likely work better with Intel Vtune.
  3. Start a PBS interactive session or submit a PBS batch job.
  4. Load a VTune module in the interactive PBS session or PBS script, as follows:
    module load vtune/2021.9

You can now run an analysis, as described in the next section.

Running a Hotspots Analysis

Run the vtune command line that is appropriate for your code, as listed below. Use the -collect (or -c) option to run the hotspots collection and the -result-dir (or -r) option to specify a directory.

Note: The vtune command replaces amplxe-cl, which was used prior to the 2020.0 version.

Running a Hotspots Analysis on Serial or OpenMP Code

To profile a serial or OpenMP application (for example):

vtune -collect hotspots -result-dir r000hs a.out

Data collected by VTune for the a.out application are stored in the r000hs directory.

Running a Hotspots Analysis on Python Code

To profile a Python application:

vtune -collect hotspots -result-dir r000hs /full/path/to/python3 python_script

Data collected by VTune while running the Python script will be stored in the r000hs directory.

Note: See Additional Resources below for more information about Python code analysis.

Running a Hotspots Analysis on MPI Code Using HPE MPT

To profile an MPI application using HPE MPT:

setenv MPI_SHEPHERD true
setenv MPI_USING_VTUNE true
mpiexec -np XX vtune -collect hotspots -result-dir r000hs a.out

Note: If your vtune run fails with MPT ERROR and a suggestion to set additional MPT environment variables, for example MPI_UNBUFFERED_STDIO, follow the suggestion and try again.

At the end of the collection, VTune generates a summary report that is written by default to stdout. The summary includes information such as the name of the compute host, operating system, CPU, elapsed time, CPU time, and average CPU utilization.

Data collected by VTune are stored and organized with one directory per host. Within each directory, data are further grouped into subdirectories by rank. As an example, for a 48-rank MPI job running on two nodes with 24 ranks per node, VTune generates two directories, r000hs.r587i0n0 and r000hs.r587i0n1, where each directory contains 24 subdirectories, (data.[0-23]).

To reduce the amount of data collected, consider profiling a subset of the MPI ranks, instead of all of them. For example, to profile only rank 0 of the 48-rank MPI job:

mpiexec -np 1 vtune -collect hotspots -result-dir r000hs  a.out : -np 47 a.out

Viewing Results with the VTune GUI

Once data are collected, view the results with the VTune graphical user interface (GUI), vtune-gui. Since the PFEs do not have sufficient memory to run vtune-gui, run it on a compute node as follows:

  1. On a PFE, run echo $DISPLAY to find its setting (for example, pfe22:102.0).
  2. On the same PFE window, start a VNC session.
  3. On your desktop, use a VNC viewer (for example, TigerVNC) to connect to the PFE.
  4. On the PFE (via the VNC viewer window), request a compute node either through an interactive PBS session
    (qsub -I -X) or a reservable front end (pbs_rfe).
  5. On the compute node, start vtune-gui with name of the result directory, for example, r000hs.
    compute_node% module load vtune/2021.9
    compute_node% vtune-gui r000hs

Generating a Report

You can also use the vtune command with the -report option to generate a report. There are several ways to group data in a report, as follows:

  • To report time grouped by functions (in descending order) and print the results to stdout, or to a specific output text file, such as output.txt:
    vtune -report hotspots -r r000hs

    or

    vtune -report hotspots -r r000hs -report-output output
  • To report time grouped by source lines, in descending order:
    vtune -report hotspots -r r000hs -group-by source-line
  • To report time grouped by module:
    vtune -report hotspots -r r000hs -group-by module

You can also generate a report showing the differences between two result directories (such as from two different ranks or two different runs), or select different types of data to display in a report, as follows:

  • To report the differences between two result directories:
    vtune -report hotspots -r r000hs -r r001hs
  • To display CPU time for call stacks:
    vtune -report callstacks -r r000hs
  • To display a call tree and provide CPU time for each function:
    vtune -report top-down -r r000hs

Additional Resources

See the following Intel VTune articles and documentation:

Contact Us

General User Assistance

Security

  • Report security issues 24x7x365
  • Toll-free: 1-877-NASA-SEC (1-877-627-2732)
  • E-mail: soc@nasa.gov

User Documentation

High-End Computing Capability (HECC) Portfolio Office

NASA High-End Computing Program

Tell Us About It

Our goal is furnish all the information you need to efficiently and effectively use the HECC resources needed for your NASA computational projects.

We welcome your input on features and topics that you would like to see included on this website.

Please send us email with your wish list and other feedback.