OpenCL Overview

The Open Standard for Parallel Programming of Heterogeneous Systems

OpenCL LogoOpenCL™ (Open Computing Language) is an open, royalty-free standard for cross-platform, parallel programming of diverse accelerators found in supercomputers, cloud servers, personal computers, mobile devices and embedded platforms. OpenCL greatly improves the speed and responsiveness of a wide spectrum of applications in numerous market categories including professional creative tools, scientific and medical software, vision processing, and neural network training and inferencing.

OpenCL is widely deployed and used throughout the industryOpenCL is widely deployed and used throughout the industry

OpenCL speeds applications by offloading their most computationally intensive code onto accelerator processors - or devices. OpenCL developers use C or C++-based kernel languages to code programs that are passed through a device compiler for parallel execution on accelerator devices. The OpenCL standard provides API calls to discover what accelerators devices are available in a system, compile and load kernel programs to those processors and coordinate their parallel execution from a host CPU.

How OpenCL applications are programmedHow OpenCL applications are programmed

OpenCL provides the industry with the lowest ‘close-to-metal’ processor-agile execution layer for accelerating applications, libraries and engines, and also providing a code generation target for compilers. Unlike ‘GPU-only’ APIs, such as Vulkan, OpenCL enables use of a diverse range of accelerators including multi-core CPUs, GPUs, DSPs, FPGAs and dedicated hardware such as inferencing engines.

How OpenCL relates to the family of Khronos acceleration standardsHow OpenCL relates to the family of Khronos acceleration standards

OpenCL Evolution

OpenCL is being actively evolved to meet the growing demands of the industry to use parallel processing to deliver ever higher levels of compute performance. OpenCL can deploy new functionality though extensions, that if proven to be useful to developers can be absorbed into new versions of the core specification. The OpenCL working group at Khronos regularly extends OpenCL for enhanced functionality and flexibility as well as increasing the quality and diversity of tools, libraries and language compilers.

OpenCL is being actively evolved to meet the growing need for parallel processingOpenCL is being actively evolved to meet the growing need for parallel processing

Deployment Flexibility

As the industry landscape of platforms and devices grows more complex, tools are evolving the enable OpenCL applications to be deployed onto platforms that do not have available native OpenCL drivers. For example, the open source clspv compiler and clvk API translator enable OpenCL applications to be run over a Vulkan run-time. This gives OpenCL developers significant flexibility on where and how they can deploy their OpenCL applications.

Open source software tools enable an OpenCL application to be executed over a Vulkan run-timeOpen source software tools enable an OpenCL application to be executed over a Vulkan run-time

OpenCL Programming Model

An OpenCL application is split into host and device parts with host code written using a general programming language such as C or C++ and compiled by a conventional compiler for execution on a host CPU.

The device compilation phase can be done online, i.e. during execution of an application using special API calls. It can alternatively be compiled before executing the application into the machine binary or special portable intermediate representation defined by Khronos called SPIR-V. There are also domain specific languages and frameworks that can compile to OpenCL either using source-to-source translations or generating binary/SPIR-V, for example Halide.

Traditional vs OpenCL programming paradigmTraditional vs OpenCL programming paradigm

Application host code is frequently written in C or C++ but bindings for other languages are also available, such as Python. Kernel programs can be written in a dialect of C (OpenCL C) or C++ (C++ for OpenCL) that enables a developer to program computationally intensive parts of their application in a kernel program. All versions of the OpenCL C language are based on C99. The community driven C++ for OpenCL language brings together capabilities of OpenCL and C++17.

C++ for OpenCL Kernel Language

The OpenCL working group has transitioned from the original OpenCL C++ kernel language first defined in OpenCL 2.0 to C++ for OpenCL developed by the open source community to provide improved features and compatibility with OpenCL C. C++ for OpenCL is supported by Clang and its documentation can be found here. It enables developers to use most C++17 features in OpenCL kernels. It is largely backwards compatible with OpenCL C 2.0 enabling it to be used to program accelerators with OpenCL 2.0 or above with conformant drivers that support SPIR-V. Its implementation in Clang can be tracked via the OpenCL Support Page.

Kernel Language Extensions

Some extensions are available to the existing published kernel language standards. The full list of such extensions is documented here . Conformant compilers and drivers may optionally support the extensions and so there is a mechanism to detect their support at the compile time. Developers should be aware that not all extensions may be supported across all devices.

OpenCL Versions

Below is the full list of OpenCL API and languages versions that are currently supported.

OpenCL 2.2

OpenCL 2.1

OpenCL 2.0

OpenCL 1.2

OpenCL 1.1

OpenCL 1.0

Kernel Languages supported by each version of OpenCL
OpenCL API Supported OpenCL Kernel Languages
OpenCL 2.0, 2.1, 2.2 OpenCL C 1.0, 1.1, 1.2, 2.0, C++ for OpenCL
OpenCL 1.2 OpenCL C 1.0, 1.1, 1.2
OpenCL 1.1 OpenCL C 1.0, 1.1
OpenCL 1.0 OpenCL C 1.0

Key OpenCL Resources

The Khronos OpenCL working group makes as much information as possible about OpenCL publicly available, including open sourcing the specification document and conformance tests:

Conformant OpenCL Implementations

Here you can view a list of hardware vendors with Conformant OpenCL Implementations

devilish