Get Started

  • 2022.1
  • 04/11/2022
  • Public Content

Get Started with the Intel® DPC++ Compatibility Tool

The 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*.
Use of the Intel® DPC++ Compatibility Tool will result in a project that is not entirely migrated. Additional work, as outlined by the output of the Intel® DPC++ Compatibility Tool, is required to complete the migration.

Before You Begin

The 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 the Intel® DPC++ Compatibility Tool. The 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, and 11.0–11.6.
You can reference custom locations by pointing to them with the
--cuda-include-path=<path/to/cuda/include>
option in the Intel® DPC++ Compatibility Tool command line.
The CUDA include path should not be the same as, or a child path of, the directory where the source code that needs to be migrated is located.
Currently, the Intel® DPC++ Compatibility Tool supports the migration of programs implemented with CUDA versions 8.0, 9.x, 10.x, and 11.0–11.6. 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
The general invocation syntax from the operating system shell is:
dpct [options] [<source0>... <sourceN>]
Built-in Usage Information
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

Emitted Warnings

The 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 DPC++ 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

The Intel® DPC++ Compatibility Tool comes with several sample projects so you can explore the tool and familiarize yourself with how it functions:
Sample Project
Description
Vector Add DPCT
  • vector_add.cu
The Vector Add DPCT sample demonstrates how to migrate a simple program from CUDA to DPC++. Vector Add provides an easy way to verify that your development environment is setup correctly to use the Intel® DPC++ Compatibility Tool.
Folder Options DPCT
  • main.cu
  • bar/util.cu
  • bar/util.h
The Folder Options DPCT sample shows how to migrate more complex projects and to use options.
Rodinia NW DPCT
  • needle.cu
  • needle.h
  • needle_kernel.cu
The Rodinia NW DPCT sample demonstrates how to migrate a Make/CMake project from CUDA to DPC++ using the Intel® DPC++ Compatibility Tool.
Review the README file provided with each sample for more detailed information about the purpose and usage of the sample project.
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 GitHub*.
For more detailed information on how to download and access the samples, visit the Intel® oneAPI Base Toolkit Get Started Guides:
Try a Sample Project
Follow these steps to migrate the Vector Add DPCT sample project using the Intel® DPC++ Compatibility Tool:
  1. Download the
    vector_add.cu
    sample.
  2. Run the Intel® DPC++ Compatibility Tool from the sample root directory:
    dpct --in-root=. src/vector_add.cu
    The
    vector_add.dp.cpp
    file should appear in the
    dpct_output
    directory. The file is now a DPC++ source file.
  3. Navigate to the new DPC++ source file:
    cd dpct_output
    Verify the generated source code and fix any code that the 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 the Intel® DPC++ Compatibility Tool, see the
    Addressing Warnings in Migrated Code
    section of the README files.
    To compile the migrated sample, add
    -I<dpct_root_folder>/include
    to your compile command.
For more complex sample instructions, see the Migrate a Project section of the Intel® DPC++ Compatibility Tool Developer Guide and Reference.

Find More

Content
Description
Detailed overview of Intel® DPC++ Compatibility Tool features, workflow, and use.
How to migrate CUDA code to Data Parallel C++ (DPC++) using the Intel® DPC++ Compatibility Tool, a one-time migration engine that ports both kernels and API calls.
Detailed instructions on how to get and install Intel® oneAPI packages using different installer modes and package managers.
The SYCL Specification PDF. Explains how SYCL integrates OpenCL devices with modern C++.
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.

Product and Performance Information

1

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