Intel® Advisor User Guide

ID 766448
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

Set Up Environment to Offload SYCL, OpenMP* target, and OpenCL™ Applications to CPU

If you have an application that contains SYCL, C++/Fortran with OpenMP* target, or OpenCL™ code and prepared for offloading to a target device, you can analyze and model its potential performance on a different target device with the it with the Intel® Advisor.

To do this, use CPU offload profiling to offload your code temporarily to a CPU so that you can profile it and model its performance with the Offload Modeling perspective.

IMPORTANT:
Offload your SYCL, C++/Fortran with OpenMP target, or OpenCL code to CPU only to analyze it with the CPU-to-GPU Offload Modeling workflow. To analyze it with the GPU-to-GPU Offload Modeling workflow or GPU Roofline workflow, configure your system to analyze GPU kernels instead.

Depending on your operating system, do one of the following:

Linux* OS

  1. For SYCL code: Force offloading to a CPU using one of the following:
    • Recommended: Set the ONEAPI_DEVICE_SELECTOR environment variable as follows:
      export ONEAPI_DEVICE_SELECTOR=opencl:cpu
    • If your application uses a SYCL device selector:
      1. In the application source code, add the following to specify the CPU as the target device:
        sycl::cpu_selector_v

        For details, see Device selectors in the SYCL Reference.

      2. Rebuild the application,
  2. For OpenMP code: Force offloading to a CPU with one of the following:
    • Recommended: To offload code to CPU, set the following environment variables:
      export OMP_TARGET_OFFLOAD=MANDATORY
      export LIBOMPTARGET_DEVICETYPE=CPU
      export LIBOMPTARGET_PLUGIN=OPENCL
    • To run code natively on CPU, set the following variable:
      export OMP_TARGET_OFFLOAD=DISABLED
  3. If your application uses 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.

Windows* OS

  1. Set the following environment variable to use the JIT profiling API:
    set INTEL_JIT_BACKWARD_COMPATIBILITY=1
  2. For SYCL code: Force offloading to a CPU using one of the following:
    • Recommended: Set the ONEAPI_DEVICE_SELECTOR environment variable as follows:
      set ONEAPI_DEVICE_SELECTOR=opencl:cpu
    • If your application uses a SYCL device selector:
      1. In the application source code, add the following to specify the CPU as the target device:
        sycl::cpu_selector_v

        For details, see Device selectors in the SYCL Reference.

      2. Rebuild the application,
  3. For OpenMP code: Force offloading to a CPU with one of the following:
    • Recommended: To offload code to CPU, set the following environment variables:
      set OMP_TARGET_OFFLOAD=MANDATORY
      set LIBOMPTARGET_DEVICETYPE=CPU
      set LIBOMPTARGET_PLUGIN=OPENCL
    • To run code natively on CPU, set the following variable:
      set OMP_TARGET_OFFLOAD=DISABLED
  4. If your application uses 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.

Next Steps