User Guide

Intel® VTune™ Profiler User Guide

ID 766319
Date 11/07/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Prepare Application for Analysis

Follow this guidance to understand how to compile an application for analysis with Intel® VTune™ Profiler and make your analysis more productive.

Recommendations for All Compiled Languages

These guidelines apply to all supported operating system hosts and compiled languages. It is highly recommended that you follow this guidance to make your use of VTune Profiler as effective as possible.

  • Do This:

    Build your application in Release mode, with maximum appropriate compiler optimization level.

    Because:

    • This eliminates performance issues that can be resolved by compiler optimizations, enabling you to focus on bottlenecks that require your attention.
  • Do This:

    Generate debug information for your application, and, if possible, download debug information for any third-party libraries it uses.

    Because:

    • This enables source-level analysis: view problematic source lines right in VTune Profiler.
    • This enables resolution of function names and proper call stack information.
    • By default, most compilers/IDEs do not generate debug information in Release mode.

Prepare a C++ Application on Windows

To fulfill the recommendations on Windows, you will need these compiler flags:

/O2 /Zi /DEBUG
  • The /O2 flag enables compiler optimizations that favor speed.
    NOTE:
    The /O2 flag is a recommendation to ensure you are profiling the Release version of your application with optimizations that favor speed enabled. If the production use of your application calls for a different optimization level, use your required level. The key idea is to profile your application when it is compiled as close to production use as possible.
  • The /Zi and /DEBUG flags enable generation of debug info in the Program Database (PDB) format.

Follow these steps to configure the optimization level and debug information generation in Microsoft Visual Studio*:

  1. Enable Release build configuration:
    1. On the Visual Studio toolbar, from the Solution Configuration drop-down list, select Release.

      This also enables the /O2 optimization level. To check, right-click on your project and open Properties > C/C++ > Optimization.

  2. Enable Debug information generation:
    1. Right-click your project and select the Properties item in the context menu.

      The Property Pages dialog opens.

    2. Make sure the Release configuration is selected in the Configuration drop-down list.
    3. From the left pane, select C++ > General.
    4. In the Debug Information Format field, choose Program Database (/Zi).
    5. From the left pane, select Linker > Debugging.
    6. In the Generate Debug Info field, select Generate Debug Information (/DEBUG).
    7. Click OK to save your changes and close the dialog box.

These steps cover the most important compiler switches that apply to all C++ applications.

Additional compiler switches are recommended for applications that use OpenMP* or Intel® oneAPI Threading Building Blocks for threading. See the Compiler Switches for Performance Analysis on Windows* Targets topic for more information.

Once you have the debug information, make sure to set the Search Directories to point VTune Profiler to the PDB and source files.

Prepare a C++ Application on Linux

To fulfill the recommendations on Linux, you will need these compiler flags:

-O2 -g
  • The -O2 flag enables compiler optimizations that favor speed.
    NOTE:
    The -O2 flag is a recommendation to ensure you are profiling the Release version of your application with optimizations that favor speed enabled. If the production use of your application calls for a different optimization level, use your required level. The key idea is to profile your application when it is compiled as close to production use as possible.
  • The -g flag enables generation of debug information.

    On Linux, VTune Profiler requires debug information in the DWARF format to enable source and call stack analysis.

    The -g option usually produces debugging information in the DWARF format. If you are having trouble generating debug information in the DWARF format, see Debug Information for Linux Binaries.

These steps cover the most important compiler switches that apply to all C++ applications.

Additional compiler switches are recommended for applications that use OpenMP* or Intel® oneAPI Threading Building Blocks for threading. See the Compiler Switches for Performance Analysis on Linux* Targets topic for more information.

Once you have the debug information, make sure to set the Search Directories to point VTune Profiler to the binary and source files.

Prepare a SYCL Application

Same basic recommendations apply to SYCL applications.

Additionally, add these flags to enable functionality specific to accelerators:

This Flag Does This

-gline-tables-only

-fdebug-info-for-profiling

Enable generating debug information for GPU analysis of a SYCL application.

-Xsprofile

Enable source-level mapping of performance data for CPU/FPGA Interaction analysis.

(Optional) Instrument Your Code

VTune Profiler also offers the Instrumentation and Tracing Technology API (ITT API) for C++ and Fortran, which enables you to:

  • generate and collect trace data for your application
  • mark logical sections—such as a multi-step data loading process—of your code and see them in VTune Profiler
  • finely balance overhead and amount of trace data
  • when necessary, eliminate all ITT API calls at compile time with a single macro, thus getting zero overhead

See the Instrumentation and Tracing Technology API section for details on configuration and usage.