User Guide

Contents

Configure DPC++, OpenCL™, and OpenMP* Target Applications

If you have a Data Parallel C++ (DPC++), C++/Fortran with OpenMP* pragmas, or OpenCL™ application that contains code that is prepared for offloading to a target device, you can analyze it with the
Intel® Advisor
and model its potential performance on a different target device.
To do this, use
CPU offload profiling
. In this approach, your GPU-enabled code is temporarily offloaded to a CPU so that you can profile it and model its performance with the
Offload Modeling
feature of the
Intel Advisor
.
CPU offload is only required to analyze GPU-enabled code with the
Offload Modeling
perspective. GPU Roofline analyzes code running on a GPU and requires you to set relevant permissions instead.
  1. Set up environment variables for Intel® oneAPI Toolkits:
    • On Linux* OS:
      source <install-dir>/setvars.sh
    • On Windows* OS:
      <install-dir>/setvars.bat
    where
    <install-dir>
    is an installation directory for Intel® oneAPI Toolkits. By default, it is
    /opt/intel/oneapi/
    on Linux OS and
    C:\Program Files (x86)\Intel\oneAPI\
    on Windows OS.
  2. On Windows OS: Set the
    INTEL_JIT_BACKWARD_COMPATIBILITY=1
    environment variable to use the JIT profiling API.
  3. For DPC++ code: Force offloading to a CPU using one of the following:
    • Set the
      SYCL_DEVICE_TYPE=CPU
      and
      SYCL_BE=PI_OPENCL
      environment variables (recommended).
    • If your application uses a SYCL device selector: In the application source code, specify the CPU as the target device using
      sycl::cpu_selector
      . For details, see Device selector in the DPC++ Reference.
  4. For OpenMP code: Force offloading to a CPU with one of the following:
    • To offload code to CPU, set the
      OMP_TARGET_OFFLOAD=MANDATORY
      and
      LIBOMPTARGET_DEVICETYPE=CPU
      variables (recommended).
    • To run code natively on CPU, set the
      OMP_TARGET_OFFLOAD=DISABLED
      variable.
    By default, the environment variables are set to
    OMP_TARGET_OFFLOAD=MANDATORY
    and
    LIBOMPTARGET_DEVICETYPE=GPU
    for OpenMP target applications to be offloaded to a GPU.
  5. For OpenCL code: Configure your code to be offloaded to a CPU. Refer to the OpenCL documentation at https://www.khronos.org/registry/OpenCL/ for specific instructions.
  6. Build your application as usual.
  7. When collecting performance metrics and modeling performance with
    Intel Advisor
    , enable analyzing dynamic (or JIT-compiled) loops.
    • From user interface:
      File
      Project Properties
      Analysis Target
      Trip Counts and FLOP Analysis
      Advanced
      Capture metrics for dynamic loops and functions
    • From command line interface: Use
      --profile-jit
      option when collecting Trip Counts data.
      The
      --profile-jit
      option automatically enables
      --assume-hide-taxes
      for performance modeling, which hides all invocation taxes except the first one in the report. For details, see Manage Invocation Taxes.

OpenMP* Example

To analyze OpenMP code with
Offload Modeling
perspective using
Intel Advisor
command line interface on Linux OS:
  1. Set up environment variables:
    source <install-dir>/setvars.sh
  2. Set up variables to offload code to CPU:
    export OMP_TARGET_OFFLOAD=MANDATORY
    export LIBOMPTARGET_DEVICETYPE=CPU
  3. Collect performance metrics with Survey analysis:
    advisor --collect=survey --stackwalk-mode=online --static-instruction-mix --project-dir=./advi -- omp_application
  4. Enable data collection for dynamic loops and functions and collect Trip Counts and FLOP data:
    advisor --collect=tripcounts --flop --enable-data-transfer-analysis --profile-jit --target-device=gen11_gt2 --project-dir=./advi -- omp_application
  5. Model application performance on a target device:
    advisor --collect=projection --no-assume-dependencies --project-dir =./advi
  6. Open the generated report in the
    Intel Advisor
    graphical user interface (GUI) or open an HTML report located at
    <project-dir>
    /e
    <NNN>
    /pp
    <NNN>
    /data.0

DPC++ Example

To analyze DPC++ code with
Offload Modeling
perspective using
Intel Advisor
GUI in Windows OS:
  1. Set up environment variables:
    <install-dir>\setvars.bat
  2. Enable JIT profiling API:
    set INTEL_JIT_BACKWARD_COMPATIBILITY=1
  3. Set up variables to offload code to CPU:
    set SYCL_DEVICE_TYPE=CPU
    set SYCL_BE=PI_OPENCL
  4. Launch the
    Intel Advisor
    GUI.
  5. Create a project for your application.
  6. Go to
    File
    Project Properties
    Analysis Target
    Trip Counts and FLOP Analysis
    Advanced
    and select
    Capture metrics for dynamic loops and functions
    to enable data collection for dynamic loops and functions.
  7. Run the
    Offload Modeling
    perspective with your desired configuration and view the report.

Product and Performance Information

1

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.