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 CPUs, GPUs, and 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.
- More easily migrate the most commonly used CUDA library APIs to SYCL.
- Migrate visual AI and imaging code to the SYCL API extension for images.
Learn How to Migrate Your Code
The Intel® DPC++ Compatibility Tool and its open source version SCYLomatic assist in migrating your existing CUDA code to SYCL code. To learn about this tool in an interactive JupyterLab environment, run self-guided tutorials (available on GitHub*).
A Jupyter* Notebook guides you through:
- The migration of a simple example
- Four step-by-step sample migrations from CUDA to SYCL (to help you with the entire porting process)
CUDA to SYCL: Adding Multiplatform Parallelism
Get an overview on how to begin with migration, plus the following topics:
- SYCL kernel template use to add code and data parallelism
- The steps for using the Intel® DPC++ Compatibility Tool and SYCLomatic
- Diagnostic message handling and resolution during migration
- Migration of CUDA math library calls
- Walk-through of an N-Body motion simulation workload migration to SYCL
Advanced Migration Tips and Tricks
Explore the following advanced topics:
- CUDA performance library mapping to specific oneAPI specification SYCL API libraries
- CPU offload kernel problem sizing
- CPU and GPU data caching, data transfer, and memory use optimization
- SYCL interoperability
- Coexistence with MPI and distributed computing in HPC
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.
Code Samples
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.
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.
This sample demonstrates the use of SYCL queues for concurrently running several kernels on a GPU.
The simpleCUDAGraphs sample shows the migration of simple explicit CUDA Graph APIs to SYCL equivalent APIs using the Taskflow programming model.
The QuasirandomGenerator sample implements Niederreiter Quasirandom Sequence Generator and Inverse Cumulative Normal Distribution functions for the generation of Standard Normal Distributions.
The convolution separable is a process in which a single convolution can be divided into two or more convolutions to produce the same output.
This sample demonstrates the use of fast Fourier transform (FFT) libraries to synthesize and render an ocean surface in real time. It showcases how to migrate from cuFFT calls to the SYCL API implementation of the Intel® oneAPI Math Kernel Library FFT domain.
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 on GitHub*, which includes the same CUDA to SYCL functionality. Community contributions are welcome.
The following guides and documentation help you migrate CUDA code using SYCLomatic.
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.
Catalog of CUDA Migration to C++ with 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.
Additional Resources
Quick Tips
- Walk-through a CUDA to SYCL Migration Using the Intel® DPC++ Compatibility Tool [4:54]
- SYCLomatic: CUDA to SYCL Automatic Migration Tool [5:56]
- How to Move from CUDA Math Library Calls to oneMKL
- Customize Moving Your CUDA Code to SYCL with User-Defined Migration Rules
- More Easily Migrate CMake* Scripts from CUDA to SYCL
Blogs
- HySEA Tsunami Simulation Aided by SYCL*
- STAC-A2*: oneAPI on Dell* PowerEdge Servers with Intel® GPU Speeds Up Finance Market Risk Analysis
- Add Multiplatform Parallelism to C++ Workloads with SYCL
- NAMD: Highly Parallel Scalable Nanoscale Simulation Powered by SYCL
- Amber: Enabling Molecular Dynamics Simulation with SYCL
- AutoDock-GPU: SYCL Enabled Molecular Screening for Science and Medicine
- Ginkgo: Linear Algebra Powered by SYCL
- Developer Ecosystem Experience: Implementing Stencil Computations in SYCL
- oneAPI Centers of Excellence: SYCL Adoption Ready for You
Case Studies
- Center for Development of Advanced Computing Achieved 1.75x Performance Improvement on Seismic Code Migrated from CUDA
- The ATLAS Experiment Implements Heterogeneous Particle Reconstruction with Intel® Tools
- Massive Image Dataset Blending Using SYCL with Intel® Max Series Processors
- INESC-ID Achieves 9x Acceleration for Epistasis Disease Detection Using Software Development Tools from Intel and Intel Hardware
- QCT* Platforms on Demand (QCT POD) Adopts Software Development Products from Intel for HPC Workloads
Webinars
Share Your Application
Showcase your work, best practices, and migration experiences, and get noticed by Intel and fellow developers on GitHub with the Awesome List of oneAPI Projects. This is a curated list of oneAPI and SYCL projects for solutions across the industry and community.
Share your migration project today.
Stay In the Know on All Things CODE
Sign up to receive the latest tech articles, tutorials, dev tools, training opportunities, product updates, and more, hand-curated to help you optimize your code, no matter where you are in your developer journey. Take a chance and subscribe. You can change your mind at any time.