Configure DPC++, OpenCL™, and OpenMP* Target Applications
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.
- 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 andC:\Program Files (x86)\Intel\oneAPI\on Windows OS. - On Windows OS: Set theINTEL_JIT_BACKWARD_COMPATIBILITY=1environment variable to use the JIT profiling API.
- For DPC++ code: Force offloading to a CPU using one of the following:
- Set theSYCL_DEVICE_TYPE=CPUandSYCL_BE=PI_OPENCLenvironment variables (recommended).
- If your application uses a SYCL device selector: In the application source code, specify the CPU as the target device usingsycl::cpu_selector. For details, see Device selector in the DPC++ Reference.
- For OpenMP code: Force offloading to a CPU with one of the following:
- To offload code to CPU, set theOMP_TARGET_OFFLOAD=MANDATORYandLIBOMPTARGET_DEVICETYPE=CPUvariables (recommended).
- To run code natively on CPU, set theOMP_TARGET_OFFLOAD=DISABLEDvariable.
By default, the environment variables are set toOMP_TARGET_OFFLOAD=MANDATORYandLIBOMPTARGET_DEVICETYPE=GPUfor OpenMP target applications to be offloaded to a GPU. - 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.
- Build your application as usual.
- When collecting performance metrics and modeling performance withIntel Advisor, enable analyzing dynamic (or JIT-compiled) loops.
- From user interface:
- From command line interface: Use--profile-jitoption when collecting Trip Counts data.The--profile-jitoption automatically enables--assume-hide-taxesfor performance modeling, which hides all invocation taxes except the first one in the report. For details, see Manage Invocation Taxes.
Continue to
create a project and run the
Offload Modeling
perspective.
OpenMP* Example
To analyze OpenMP code with
Offload Modeling
perspective using
Intel Advisor
command line interface on Linux OS:
- Set up environment variables:source <install-dir>/setvars.sh
- Set up variables to offload code to CPU:export OMP_TARGET_OFFLOAD=MANDATORYexport LIBOMPTARGET_DEVICETYPE=CPU
- Collect performance metrics with Survey analysis:advisor --collect=survey --stackwalk-mode=online --static-instruction-mix --project-dir=./advi -- omp_application
- 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
- Model application performance on a target device:advisor --collect=projection --no-assume-dependencies --project-dir =./advi
- Open the generated report in theIntel Advisorgraphical 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:
- Set up environment variables:<install-dir>\setvars.bat
- Enable JIT profiling API:set INTEL_JIT_BACKWARD_COMPATIBILITY=1
- Set up variables to offload code to CPU:set SYCL_DEVICE_TYPE=CPUset SYCL_BE=PI_OPENCL
- Launch theIntel AdvisorGUI.
- Create a project for your application.
- Go toand selectCapture metrics for dynamic loops and functionsto enable data collection for dynamic loops and functions.
- Run theOffload Modelingperspective with your desired configuration and view the report.