# SYCL

SYCL (pronounced "sickle") is a higher-level programming model to improve programming productivity on various hardware accelerators. It is a single-source embedded domain-specific language (eDSL) based on pure C++17. It is a standard developed by Khronos Group, announced in March 2014.

## Origin of the name

SYCL (pronounced ‘sickle’) originally stood for SYstem-wide Compute Language, but since 2020 SYCL developers have stated that SYCL is a name and have made clear that it is no longer an acronym and contains no reference to OpenCL.

## Purpose

SYCL is a royalty-free, cross-platform abstraction layer that builds on the underlying concepts, portability and efficiency inspired by OpenCL that enables code for heterogeneous processors to be written in a “single-source” style using completely standard C++. SYCL enables single-source development where C++ template functions can contain both host and device code to construct complex algorithms that use hardware accelerators, and then re-use them throughout their source code on different types of data.
While the SYCL standard started as the higher-level programming model sub-group of the OpenCL working group and was originally developed for use with OpenCL and SPIR, SYCL is a Khronos Group workgroup independent from the OpenCL working group since September 20, 2019 and starting with SYCL 2020, SYCL has been generalized as a more general heterogeneous framework able to target other systems. This is now possible with the concept of a generic backend to target any acceleration API while enabling full interoperability with the target API, like using existing native libraries to reach the maximum performance along with simplifying the programming effort. For example, the Open SYCL implementation targets ROCm and CUDA via AMD's cross-vendor HIP.

## Versions

SYCL was introduced at GDC in March 2014 with provisional version 1.2, then the SYCL 1.2 final version was introduced at IWOCL 2015 in May 2015.
The latest version for the previous SYCL 1.2.1 series is SYCL 1.2.1 revision 7 which was published on April 27, 2020 (the first version was published on December 6, 2017).
SYCL 2.2 provisional was introduced at IWOCL 2016 in May 2016 targeting C++14 and OpenCL 2.2. But the SYCL committee preferred not to finalize this version and to move towards a more flexible SYCL specification to address the increasing diversity of current hardware accelerators, including artificial intelligence engines, which led to SYCL 2020.
The latest version is SYCL 2020 revision 6 which was published on November 13, 2022, an evolution from first release of revision 2 which was published on February 9, 2021, taking into account the feedback from users and implementors on the SYCL 2020 Provisional Specification revision 1 published on June 30, 2020. C++17 and OpenCL 3.0 support are main targets of this release. Unified shared memory (USM) is one main feature for GPUs with OpenCL and CUDA support.
At IWOCL 2021 a roadmap was presented. DPC++, ComputeCpp, Open SYCL, triSYCL and neoSYCL are the main implementations of SYCL. Next Target in development is support of C++20 in future SYCL 202x.

## Implementations

* Data Parallel C++ (DPC++): an open source project of Intel to introduce SYCL for LLVM and oneAPI. C++17 and parts of C++20 with SYCL 2020 are base of this compiler framework.
* ComputeCpp: SYCL 1.2.1 conformant framework of firm Codeplay with community version. Now deprecated in favor of DPC++.
* AdaptiveCpp (formerly hipSYCL and Open SYCL): incomplete 1.2.1 support without Images or OpenCL interop; partly SYCL 2020. Supports AMD (ROCm), Nvidia (CUDA), Intel (Level Zero via SPIR-V), and CPUs (LLVM + OpenMP). Can produce fully generic binaries using a just-in-time runtime. Supports C++ standard parallelism (std::execution) in addition to SYCL.
* triSYCL: based on C++20, OpenMP and OpenCL, slow development, incomplete, with a version based on top of DPC++
* neoSYCL: SYCL 1.2.1 nearly complete, for hpc SX-Aurora Tsubasa, no OpenCL specific features like image support
* SYCL-gtx: C++11 support, for OpenCL 1.2+, far from complete, no actual development
* Sylkan is an implementation of SYCL to Vulkan devices in an experimental state.
* Polygeist has a fork compiling SYCL through MLIR which is backed by the Inteon company.

## Extensions
### SYCL safety critical

In March 2023 the Khronos Group announced the creation of the SYCL SC Working Group, with the objective of creating a high-level heterogeneous computing framework for safety-critical systems. These systems span various fields, including avionics, automotive, industrial, and medical sectors.
The SYCL Safety Critical framework will comply with several industry standards to ensure its reliability and safety. These standards include MISRA C++ 202X, which provides guidelines for the use of C++ in critical systems, RTCA DO-178C / EASA ED-12C, which are standards for software considerations in airborne systems and equipment certification, ISO 26262/21448, which pertains to the functional safety of road vehicles, IEC 61508, which covers the functional safety of electrical/electronic/programmable electronic safety-related systems, and IEC 62304, which relates to the lifecycle requirements for medical device software.

## Software

Some notable software fields that make use of SYCL include the following (with examples):
* Bioinformatics
** GROMACS: A molecular dynamics software widely used in bioinformatics and computational chemistry. Starting from its accelerated version in 2021, GROMACS utilizes SYCL 2020 for efficient computation on various hardware accelerators.
** LiGen: A molecular docking software that utilizes SYCL for accelerating computational tasks related to molecular structure analysis and docking simulations.
** Autodock: Another molecular docking software that leverages SYCL to accelerate the process of predicting how small molecules bind to a receptor of a known 3D structure.
* Artificial Intelligence
** llama.cpp: An open source software library that performs inference on various Large Language Models such as Llama.
* Automotive Industry
** ISO 26262: The international standard for functional safety of automotive electrical and electronic systems. SYCL is used in automotive applications to accelerate safety-critical computations and simulations, ensuring compliance with stringent safety standards.
* Cosmology
** CRK-HACC: A cosmological n-body simulation code that has been ported to SYCL. It uses SYCL to accelerate calculations related to large-scale structure formation and dynamics in the universe.

## Resources

Khronos Maintains a list of SYCL resource. Codeplay Software also provides tutorials on the website sycl.tech along with other information and news on the SYCL ecosystem.

## License

The source files for building the specification, such as Makefiles and some scripts, the SYCL headers and the SYCL code samples are under the Apache 2.0 license.

## Comparison with other Tools

The open standards SYCL and OpenCL are similar to the programming models of the proprietary stack CUDA from Nvidia and HIP from the open-source stack ROCm, supported by AMD.
In the Khronos Group realm, OpenCL and Vulkan are the low-level non-single source APIs, providing fine-grained control over hardware resources and operations. OpenCL is widely used for parallel programming across various hardware types, while Vulkan primarily focuses on high-performance graphics and computing tasks.
SYCL, on the other hand, is the high-level single-source C++ embedded domain-specific language (eDSL). It enables developers to write code for heterogeneous computing systems, including CPUs, GPUs, and other accelerators, using a single-source approach. This means that both host and device code can be written in the same C++ source file.

### CUDA

By comparison, the single-source C++ embedded domain-specific language version of CUDA, which is named "CUDA Runtime API," is somewhat similar to SYCL. In fact, Intel released a tool called SYCLOMATIC that automatically translated code from CUDA to SYCL. However, there is a less known non-single-source version of CUDA, which is called "CUDA Driver API," similar to OpenCL, and used, for example, by the CUDA Runtime API implementation itself.
SYCL extends the C++ AMP features, relieving the programmer from explicitly transferring data between the host and devices by using buffers and accessors. This is in contrast to CUDA (prior to the introduction of Unified Memory in CUDA 6), where explicit data transfers were required. Starting with SYCL 2020, it is also possible to use Unified Shared Memory (USM) to augment, rather than replace, the buffer-based interfaces, providing a lower-level programming model similar to Unified Memory in CUDA.
SYCL is higher-level than C++ AMP and CUDA since you do not need to build an explicit dependency graph between all the kernels, and it provides you with automatic asynchronous scheduling of the kernels with communication and computation overlap. This is all done by using the concept of accessors without requiring any compiler support.
Unlike C++ AMP and CUDA, SYCL is a pure C++ eDSL without any C++ extension. This allows for a basic CPU implementation that relies on pure runtime without any specific compiler.
Both DPC++ and AdaptiveCpp compilers provide a backend to NVIDIA GPUs, similar to how CUDA does. This allows SYCL code to be compiled and run on NVIDIA hardware, allowing developers to leverage SYCL's high-level abstractions on CUDA-capable GPUs.

### ROCm HIP

ROCm HIP targets Nvidia GPU, AMD GPU, and x86 CPU. HIP is a lower-level API that closely resembles CUDA's APIs. For example, AMD released a tool called HIPIFY that can automatically translate CUDA code to HIP. Therefore, many of the points mentioned in the comparison between CUDA and SYCL also apply to the comparison between HIP and SYCL.
ROCm HIP has some similarities to SYCL in the sense that it can target various vendors (AMD and Nvidia) and accelerator types (GPU and CPU). However, SYCL can target a broader range of accelerators and vendors. SYCL supports multiple types of accelerators simultaneously within a single application through the concept of backends. Additionally, SYCL is written in pure C++, whereas HIP, like CUDA, uses some language extensions. These extensions prevent HIP from being compiled with a standard C++ compiler.
Both DPC++ and AdaptiveCpp compilers provide backends for NVIDIA and AMD GPUs, similar to how HIP does. This enables SYCL code to be compiled and executed on hardware from these vendors, offering developers the flexibility to leverage SYCL's high-level abstractions across a diverse range of devices and platforms.

### Kokkos

SYCL has many similarities to the Kokkos programming model, including the use of opaque multi-dimensional array objects (SYCL buffers and Kokkos arrays), multi-dimensional ranges for parallel execution, and reductions (added in SYCL 2020). Numerous features in SYCL 2020 were added in response to feedback from the Kokkos community.
SYCL focuses more on heterogeneous systems; thanks to its integration with OpenCL, it can be adopted on a wide range of devices. Kokkos, on the other hand, targets most of the HPC platforms, thus it is more HPC-oriented for performance.
As of 2024, the Kokkos team is developing a SYCL backend, which enables Kokkos to target Intel hardware in addition to the platforms it already supports. This development broadens the applicability of Kokkos and allows for greater flexibility in leveraging different hardware architectures within HPC applications.

### Raja

Raja is a library of C++ software abstractions to enable the architecture and programming portability of HPC applications.
Like SYCL, it provides portable code across heterogeneous platforms. However, unlike SYCL, Raja introduces an abstraction layer over other programming models like CUDA, HIP, OpenMP, and others. This allows developers to write their code once and run it on various backends without modifying the core logic. Raja is maintained and developed at Lawrence Livermore National Laboratory (LLNL), whereas SYCL is an open standard maintained by the community.
Similar to Kokkos, Raja is more tailored for HPC use cases, focusing on performance and scalability in high-performance computing environments. In contrast, SYCL supports a broader range of devices, making it more versatile for different types of applications beyond just HPC.
As of 2024, the Raja team is developing a SYCL backend, which will enable Raja to also target Intel hardware. This development will enhance Raja's portability and flexibility, allowing it to leverage SYCL's capabilities and expand its applicability across a wider array of hardware platforms.

### OpenMP

OpenMP targets computational offloading to external accelerators, primarily focusing on multi-core architectures and GPUs. SYCL, on the other hand, is oriented towards a broader range of devices due to its integration with OpenCL, which enables support for various types of hardware accelerators.
OpenMP uses a pragma-based approach, where the programmer annotates the code with directives, and the compiler handles the complexity of parallel execution and memory management. This high-level abstraction makes it easier for developers to parallelize their applications without dealing with the intricate details of memory transfers and synchronization.
Both OpenMP and SYCL support C++ and are standardized. OpenMP is standardized by the OpenMP Architecture Review Board (ARB), while SYCL is standardized by the Khronos Group.
OpenMP has wide support from various compilers, like GCC and Clang.

### std::par

std::par is part of the C++17 standard and is designed to facilitate the parallel execution of standard algorithms on C++ standard containers. It provides a standard way to take advantage of external accelerators by allowing developers to specify an execution policy for parallel operations, such as std::for_each, std::transform, and std::reduce. This enables efficient use of multi-core processors and other parallel hardware without requiring significant changes to the code.
SYCL can be used as a backend for std::par, enabling the execution of standard algorithms on a wide range of external accelerators, including GPUs from Intel, AMD, and NVIDIA, as well as other types of accelerators. By leveraging SYCL's capabilities, developers can write standard C++ code that seamlessly executes on heterogeneous computing environments. This integration allows for greater flexibility and performance optimization across different hardware platforms.
The use of SYCL as a backend for std::par is compiler-dependent, meaning it requires a compiler that supports both SYCL and the parallel execution policies introduced in C++17. Examples of such compilers include DPC++ and other SYCL-compliant compilers. With these compilers, developers can take advantage of SYCL's abstractions for memory management and parallel execution while still using the familiar C++ standard algorithms and execution policies.