Ahead of Time Compilation

Ahead of Time (AOT) Compilation is a helpful feature for your development lifecycle or distribution time. It benefits you when you know beforehand what your target device is going to be at application execution time. The AOT feature provides the following benefits:

Note

The program built with AOT compilation for a specific target device will not run on a non-specific device. You must detect the proper target device at runtime and report an error if the targeted device is not present. The use of exception handling with an asynchronous exception handler is recommended.

Data Parallel C++ (DPC++) supports AOT compilation for the following targets: Intel® CPUs, Intel® Processor Graphics (Gen9 or above), and Intel® FPGA.

Prerequisites

To target a GPU with the AOT feature, you must have the OpenCL™ Offline Compiler (OCLOC) tool installed. OCLOC can generate binaries that utilize OpenCL™ or the Intel® oneAPI Level Zero backend.

Linux*

OCLOC is not packaged with the Linux version of Intel® oneAPI DPC++/C++ Compiler and must be installed separately. Refer to Install OpenCL™ Offline Compiler (OCLOC) for details.

Windows*

OCLOC is packaged with the Windows version of Intel® oneAPI DPC++/C++ Compiler.

Use AOT for the Target Device (Intel® CPUs)

The supported options are:

Note

-Xs is a general device target option. If there are multiple targets desired (example: -fsycl-targets=spir64_gen,spir64_x86_64) the use of -Xs "opt" applies to all targets. This is not desired for multiple targets. You can use -Xsycl-target-backend=spir64_gen "opt" and -Xsycl-target-backend=spir64_x86_64 "opt" to add specificity.

Examples:

Build an Application with Multiple Source Files for CPU Targeting

Method 1: Compile your normal files (with no DPC++ kernels) to create host objects. Then compile the file with the kernel code and link it with the rest of the application.

Method 2: Compile the file with the kernel code and create a fat object. Then compile the rest of the files and linking to create a fat executable:

Note

Currently, Method 2 only works on a HOST selector.

Use AOT for Intel® Integrated Graphics (Intel® GPU)

The supported options are:

To see the complete list of supported target device types for your installed version of OCLOC, run:

ocloc compile --help

If multiple target devices are listed in the compile command, the Intel® oneAPI DPC++/C++ Compiler compiles for each of these targets and creates a fat-binary that contains all the device binaries produced this way.

Examples of supported -device patterns:

Build an Application with Multiple Source Files for GPU Targeting

Method 1: Compile your normal files (with no DPC++ kernels) to create host objects. Then compile the file with the kernel code and link it with the rest of the application.

Method 2: Compile the file with the kernel code and create a fat object. Then compile the rest of the files and linking to create a fat executable:

Note

Currently, Method 2 only works on a HOST selector.

Use AOT in Microsoft Visual Studio*

You can use Microsoft Visual Studio for compiling and linking. Set the flags below to use AOT compilation for CPU or GPU.

For CPU:

For GPU:

See Also