Get Started with Intel® DPC++ Compatibility Tool
Intel® DPC++ Compatibility Tool assists in the migration of a developer’s program that is written in CUDA* to a program written in Data Parallel C++ (DPC++), which is based on modern C++ and incorporates portable industry standards such as SYCL*.
Visit the Intel® DPC++ Compatibility Tool Developer Guide and Reference for additional information about the tool.
Visit the Release Notes for known issues and the most up-to-date information.
Before You Begin
Intel® DPC++ Compatibility Tool is included in the Intel® oneAPI Base Toolkit. If you have not installed the Intel® oneAPI Base Toolkit, follow the instructions in the Installation Guide.
Certain CUDA header files (specific to your project) may need to be accessible to Intel® DPC++ Compatibility Tool. Intel® DPC++ Compatibility Tool looks for these CUDA header files in the default locations:
/usr/local/cuda/include
/usr/local/cuda-x.y/include, where x.y is one of these values: 8.0, 9.x, 10.x, 11.x, and 12.0.
You can reference custom locations by pointing to them with the --cuda-include-path=<path/to/cuda/include> option in Intel® DPC++ Compatibility Tool command line.
Currently, Intel® DPC++ Compatibility Tool supports the migration of programs implemented with CUDA versions 8.0, 9.x, 10.x, 11.x, and 12.0. The list of supported languages and versions may be extended in the future.
To set up the Intel® DPC++ Compatibility Tool environment, run the following:
On Linux (sudo): source /opt/intel/oneapi/setvars.sh
On Linux (user): source ~/intel/oneapi/setvars.sh
On Windows: Drive:\Program Files (x86)\Intel\oneAPI\setvars.bat
Invoke the Tool
The general invocation syntax from the operating system shell is:
dpct [options] [<source0>... <sourceN>]
To see the list of Intel® DPC++ Compatibility Tool–specific options, use --help:
dpct --help
To see the list of the language parser (Clang*) options, pass -help as the Clang option:
dpct -- -help
Specify Files to Migrate
If no directory or file is specified for migration, the tool will try to migrate source files found in the current directory. The default output directory is dpct_output. Use the --out-root option to specify an output directory.
You can optionally provide file paths for source files that should be migrated. The paths can be found in the compilation database. The following examples show ways to specify a file or directory for migration.
Migrate single source file:
dpct source.cpp
Migrate all files available in compilation database:
dpct -p=<path to location of compilation database file>
Migrate one file in compilation database:
dpct -p=<path to location of compilation database file> source.cpp
Migrate source files in the directory specified by the --in-root option and place generated files in the directory specified by the --out-root option:
dpct --in-root=foo --out-root=bar
Emitted Warnings
Intel® DPC++ Compatibility Tool identifies the places in the code that may require your attention during the migration of the files in order to make the code SYCL compliant or correct.
Comments are inserted into the generated source files and displayed as warnings in the output. For example:
/path/to/file.hpp:26:1: warning: DPCT1003:0: Migrated API does not return error code. (*,0) is inserted. You may need to rewrite this code. // source code line for which warning was generated ^
For more details on what a specific warning means, refer to the Diagnostic Reference.
Migrate a Simple Test Project
Several sample projects for Intel® DPC++ Compatibility Tool are available to explore the tool and familiarize yourself with how it functions.
To access the samples
-
- use the oneapi-cli utility to select a sample from the Intel® DPC++ Compatibility Tool
-
category, or
-
- download the samples from
For more detailed information on how to download and access the samples, visit the Intel® oneAPI Base Toolkit Get Started Guides:
Sample Project |
Description |
---|---|
Vector Add
|
The Vector Add sample demonstrates how to migrate a simple program from CUDA* to SYCL*. Vector Add provides an easy way to verify that your development environment is setup correctly to use Intel® DPC++ Compatibility Tool. |
Folder Options
|
The Folder Options sample shows how to migrate more complex projects and to use options. |
Rodinia needleman-wunsch
|
The Rodinia needleman-wunsch sample demonstrates how to migrate a Make/CMake* project from CUDA to SYCL. |
Review the README file provided with each sample for more detailed information about the purpose and usage of the sample project.
Try a Sample Project
The following steps show how to migrate the Vector Add sample using Intel® DPC++ Compatibility Tool:
Download the Vector Add sample.
Navigate to the root of the Vector Add sample. The sample contains a single CUDA file, vector_add.cu, located in the src folder.
From the root folder of the sample project, run Intel® DPC++ Compatibility Tool:
dpct --in-root=. src/vector_add.cu
The --in-root option specifies the root location of the program sources that should be migrated. Only files and folders located within the --in-root directory will be considered for migration by the tool. Files located outside the --in-root directory will not be migrated, even if they are included by a source file located within the --in-root directory. By default, the migrated files are created in a new folder named dpct_output.
As a result of the migration command, you should see the new SYCL source file in the output folder:
dpct_output └── src └── vector_add.dp.cpp
The relative paths of the migrated files are maintained.
Navigate to the new SYCL source file:
cd dpct_output/src
Verify the migrated source code and fix any code that Intel® DPC++ Compatibility Tool was unable to migrate. (The code used in this example is simple, so manual changes may not be needed).
For the most accurate and detailed instructions on addressing warnings emitted from Intel® DPC++ Compatibility Tool, see the Addressing Warnings in Migrated Code section of the README files.
NOTE:To compile the migrated sample, add -I<dpct_root_folder>/include to your compile command.
For more complex sample instructions, refer to the Migrate a Project section of the Intel® DPC++ Compatibility Tool Developer Guide and Reference.
Find More
Content |
Description |
---|---|
Intel® DPC++ Compatibility Tool Developer Guide and Reference |
Detailed overview of Intel® DPC++ Compatibility Tool features, workflow, and use. |
On-Demand Webinar: Migrating Your Existing CUDA Code to DPC++ Code |
|
|
|
|
|
The SYCL 2020 Specification PDF. |
|
An overview of SYCL provided by the Khronos Group. |
|
Description of CUDA support in clang. |
|
Proposed extensions to the SYCL specification. |
|
Add oneAPI components to a Yocto project build using the meta-intel layers. |
* SYCL is a registered trademark of the Kronos Group, Inc.