The Intel® DPC++ Compatibility Tool helps users streamline and simplify migrating original CUDA* projects to C++ projects with SYCL*.
With release 2024.1 and newer, it now supports the migration of CMake build scripts by migrating CUDA specific CMake syntax to a SYCL version. Two command line options are provided to trigger the migration of CMake build scripts:
- --migrate-build-script=CMake - EXPERIMENTAL: Migrate the CMake file(s).
- --migrate-build-script-only - EXPERIMENTAL: Only migrate the build script(s). Default: off.
Example of CMake Build Script Migration
This example uses the Velocity Bench BitCracker workload to demonstrate the migration of CMake build script, following three high-level steps:
- Create the Compilation Database from the Original CMake-based Project.
- Migrate the project and CMake Build Script with the Migration Tool.
- Verify the Migrated Source and CMake Build Script.
You can access the reference source code project here.
Step 1: Create the Compilation Database from the Original CMake-based Project
- Get the Velocity Bench BitCracker code from GitHub*.
- Before running intercept-build, configure and generate your Makefile out of the original CMakeLists.txt by following the build instructions for CUDA.
$ cd Velocity-Bench/bitcracker/CUDA
$ mkdir build
$ cd build
$ CXX=nvcc cmake -DUSE_SM=80 ..
- Invoke the build command, prepending it with intercept-build.
$ make clean
$ intercept-build make
This creates the file compile_commands.json in the working directory.
The intercept-build script runs your project’s build command without building the original program. It records all the compiler invocations and stores the names of the input files and the compiler options in the compilation database file compile_commands.json.
Step 2: Migrate the Project and CMake Build Script with the Migration Tool
By default, Intel® DPC++ Compatibility Tool looks for the compile_commands.json file in the current directory and uses its compiler options for each input file.
The following command migrates the CUDA code and CMake build script using the compilation database generated in the previous step:
$ dpct -p ./compile_commands.json --in-root=../ --out-root= dpct_output --migrate-build-script=CMake
The “--migrate-build-script=CMake” option makes the migration tool migrate both the project and CMake build script. If only the CMake build script migration is required, it can be replaced with option “--migrate-build-script-only”.
After running the migration command, you should see the following files in the dpct_output output folder:
dpct_output
└── CMakeLists.txt
└── MainSourceFiles.yaml
└── src
Step 3: Verify the Migrated Source and CMake Build Script
- Configure and generate your Makefile out of the migrated CMakeLists.txt.
$ cd dpct_output
$ mkdir build
$ cd build
$ cmake -DCMAKE_CXX_COMPILER=icpx ..
- Build the migrated source
$ make
Migrate your CMake Build Script from CUDA to SYCL Today
Porting complete CMake based projects from CUDA to SYCL just got easier. Join us on the journey towards multiarchitecture performance portability.
Get the stand-alone version of the Intel DPC++ Compatibility Tool or as part of the Intel® oneAPI Base Toolkit—a core set of tools and libraries for developing high-performance, data-centric applications across diverse architectures.
Additional Resources
- Intel® DPC++ Compatibility Tool Developer Guide and Reference
- CUDA to SYCL Migration Portal
- Intel® oneAPI DPC++/C++ Compiler
- Intel® oneAPI Base Toolkit