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 of how to begin with migration, plus the following topics:
- Use of SYCL kernel template 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
Experiences Migrating CUDA to SYCL: A Molecular Docking Case Study
"Our team is highly satisfied with how oneAPI has streamlined the porting and optimization of our data-parallel computing and simulation software for pharmaceutical research to multiple targets. Given our positive experience within the Intel ecosystem, we are eager to see SYCL gain wide acceptance in a multivendor context."
– Professor Andreas Koch, Technische Universität Darmstadt
Hyperbolic Systems and Efficient Algorithms (HySEA) Tsunami Simulation
"Migrating our tsunami simulation and prediction code 'Tsunami HySEA' from CUDA to SYCL was a decision that allowed our users and us to be independent of individual hardware vendors. Previously, the application required NVIDIA* GPUs. Now, with just one source code, the application runs with a similar performance on NVIDIA hardware, but can also run on other vendors' CPUs and GPUs, such as Intel® Data Center GPU Max Series. With a very good performance, its ability to run on different platforms, and a seamless transition process, SYCL has become an extremely useful tool for our parallel computing efforts. We recommend SYCL to any organization that wants to realize the full potential of heterogeneous computing and achieve excellent performance on multiple platforms using a single code.”
– EDANYA Group at University of Málaga
Nearly 50 Years Old & as Powerful as Ever: Amber* Molecular Simulation
Power Amber molecular dynamics simulations on GPUs with SYCL. Unlock a suite of biomolecular simulation programs that use oneAPI 2024.0 and the Intel® Data Center GPU Max Series, designed to handle many of the standard PMEMD v18 features for biochemists.
"We are excited to join the circle of other top research institutions as a newly established Intel oneAPI Center of Excellence. We look forward to collaborating with Intel’s experts to apply the huge strides oneAPI has made over other programming models to realize better and faster docking simulation tools, with the potential to scale from individual researchers' workstations up to supercomputers."
— Professor Andreas Koch, principal investigator at the Intel oneAPI Center of Excellence at the Technical University of Darmstadt
Empowering GROMACS Cross-Architecture Development
"The motto of GROMACS is 'Fast, Flexible, Free'—values that align with those of the SYCL standard. Starting in 2020, GROMACS began to utilize SYCL as a performance-portability back end, leveraging select features of SYCL 2020 even before its official standardization. Compared to its predecessor SYCL 1.2.1, the SYCL 2020 standard introduces several new features that are instrumental in enhancing both application performance and developer productivity. The achievement of the Intel® oneAPI DPC++/C++ Compiler in attaining certification as the first fully conformant SYCL 2020 toolchain marks a significant milestone for the widespread adoption of open standards in heterogeneous parallelization within high-performance computing."
— Andrey Alekseenko, researcher, SciLifeLab and KTH Royal Institute of Technology
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.