Migrate from CUDA* to C++ with SYCL*
Unlock your code from the constraints of vendor-specific tools and accelerators.
Introduction
C++ and SYCL* deliver a unified programming model, performance portability, and C++ alignment for applications using accelerators. Explore the following sections to:
- Learn how to migrate your code to SYCL.
- Download the software to get started.
- See examples from other users.
- Join the community to showcase your own migration projects.
- Continue to target your existing CUDA* supported hardware.
Learn How to Migrate Your Code
The Intel® DPC++ Compatibility Tool assists in migrating your existing CUDA code to SYCL code. To learn about this tool in an interactive JupyterLab environment, on your local machine, run this self-guided tutorial.
A Jupyter* Notebook guides you through:
- The migration of a simple example
- Two real-world sample migrations from CUDA to SYCL (to help you with the entire porting process)
Quickly Migrate CUDA Code to SYCL
Watch the video for examples of migrations. It covers these topics:
- Overview of standards-based C++ with SYCL
- Description of the Intel DPC++ Compatibility Tool and how it works
- Hands-on demonstrations with real-world examples
- Discussion of common tasks required to complete the migration
Target Your Existing CUDA Supported Hardware
- To use an AMD* GPU with the Intel® oneAPI DPC++ Compiler, install the oneAPI for AMD GPUs plug-in from Codeplay*.
- To use an NVIDIA* GPU with the Intel oneAPI DPC++ Compiler, install the oneAPI for NVIDIA GPUs plug-in from Codeplay.
Examples
The following end-to-end migration samples demonstrate how real-world CUDA algorithms can be migrated to the SYCL heterogeneous programming language.
Find approximate numerical solutions for systems of linear equations of the form Ax = b in numerical linear algebra, which is diagonally dominant.
This graph-traversal motif belongs to a sorting networks class. It's a preferred algorithm for sorting batches of short-sized to mid-sized (key, value) array pairs.
Optical flow is the pattern of apparent motion of image objects between two consecutive frames caused by the movement of an object or camera.
Migrate the MonteCarloMultiGPU Sample from CUDA to SYCL
Evaluate a fair call price for a given set of European options using the Monte Carlo approach. This sample uses a single CPU thread to control multiple GPUs.
Migrate the ConcurrentKernels Application from CUDA to SYCL
This sample demonstrates the use of SYCL queues for concurrently running several kernels on a GPU.
Migrate the SimpleCUDAGraphs from CUDA to SYCL
The simpleCUDAGraphs sample shows the migration of simple explicit CUDA Graph APIs to SYCL equivalent APIs using the Taskflow programming model.
Migrate and Optimize the QuasirandomGenerator from CUDA to SYCL
The QuasirandomGenerator sample implements Niederreiter Quasirandom Sequence Generator and Inverse Cumulative Normal Distribution functions for the generation of Standard Normal Distributions.
Migrate and Optimize the Convolution Separable from CUDA to SYCL
The convolution separable is a process in which a single convolution can be divided into two or more convolutions to produce the same output.
Port Your Code
Migrate your existing CUDA code to a multiplatform program in SYCL.
Download the SYCLomatic Tool
In response to developer requests, the Intel DPC++ Compatibility Tool was released as the open source project SYCLomatic, which includes the same CUDA to SYCL functionality. Community contributions are welcome.
To install the SYCLomatic tool on a CUDA development machine, do the following:
- Go to SYCLomatic releases (GitHub).
- To find the latest Linux* release, browse through the releases and select Assets.
- Copy the link address to the latest linux_release.tgz
- Run the following command sequence on your CUDA development machine:
$ mkdir syclomatic; cd syclomatic
$ wget <link address to linux_release.tgz>
$ tar -cvf linux_release.tgz
$ export PATH="/home/$USER/syclomatic/bin:$PATH"
$ c2s --version
Download the Intel DPC++ Compatibility Tool
The Intel® oneAPI Base Toolkit contains the Intel DPC++ Compatibility Tool. The tool ports CUDA language kernels and library API calls, migrating 80 percent to 90 percent of CUDA to SYCL. In addition, it generates in-line comments that help you finish writing and tuning your code.
The following guides help you migrate CUDA code using the Intel DPC++ Compatibility Tool.
Workflow for a CUDA to SYCL Migration
Examples of CUDA Migration to SYCL
CUDA Portability with HIPCL and Intel® DPC++ Compatibility Tool
Zheming Jin, a researcher at Oak Ridge National Laboratory (ORNL), evaluates DPC++ by porting several benchmarking applications.
Move CUDA-Optimized Kernels to Intel® GPUs Using Intel oneAPI
Eric Nielson (a research scientist at NASA*) and Dr. Mohammad Zubair (a computer science professor at Old Dominion University) share their experiences with moving kernels optimized for CUDA to oneAPI.
Bring SYCL to Pre-exascale Supercomputing with DPC++ for CUDA
Gordon Brown (a principal software engineer at Codeplay*) talks about scaling kernels migrated with SYCL to pre-exascale machines.
Empowering GROMACS Cross-Architecture Development
Erik Lindahl (a biophysics professor at the University of Stockholm who works on GROMACS) migrated CUDA code to SYCL using the Intel DPC++ Compatibility Tool for cross-architecture-ready code.
Stay in the Know with All Things CODE
Sign up to receive the latest trends, tutorials, tools, training, and more to
help you write better code optimized for CPUs, GPUs, FPGAs, and other
accelerators—stand-alone or in any combination.