GPGPU stands for General-purpose computing on graphics processing units. In Linux, there are currently two major GPGPU frameworks: OpenCL and CUDA.
- 1 OpenCL
- 2 SYCL
- 3 CUDA
- 4 List of GPGPU accelerated software
- 5 Links and references
OpenCL (Open Computing Language) is an open, royalty-free parallel programming specification developed by the Khronos Group, a non-profit consortium.
The OpenCL specification describes a programming language, a general environment that is required to be present, and a C API to enable programmers to call into this environment.
To execute programs that use OpenCL, a compatible hardware runtime needs to be installed.
- AMDGPU and Radeon : free runtime for
- AMDGPU AUR: proprietary standalone runtime for
- AMDGPU PRO AUR: proprietary runtime for
- AMDGPU AUR: AMD proprietary runtime, soon to be deprecated in favor of
- AUR: AMD CPU runtime
- NVIDIA runtime : official
- : a.k.a. the Neo OpenCL runtime, the open-source implementation for Intel HD Graphics GPU on Gen8 (Broadwell) and beyond.
- : the open-source implementation for Intel HD Graphics GPU on Gen7 (Ivy Bridge) and beyond, deprecated by Intel in favour of NEO OpenCL driver, remains recommended solution for legacy HW platforms (e.g. Ivy Bridge, Sandy Bridge, Haswell).
- AUR: the proprietary implementation for Intel HD Graphics GPU on Gen7 (Ivy Bridge) and beyond, deprecated by Intel in favour of NEO OpenCL driver, remains recommended solution for legacy HW platforms (e.g. Ivy Bridge, Sandy Bridge, Haswell).
- AUR: the implementation for Intel Core and Xeon processors. It also supports non-Intel CPUs.
- AUR: LLVM-based OpenCL implementation
OpenCL ICD loader (libOpenCL.so)
The OpenCL ICD loader is supposed to be a platform-agnostic library that provides the means to load device-specific drivers through the OpenCL API. Most OpenCL vendors provide their own implementation of an OpenCL ICD loader, and these should all work with the other vendors' OpenCL implementations. Unfortunately, most vendors do not provide completely up-to-date ICD loaders, and therefore Arch Linux has decided to provide this library from a separate project () which currently provides a functioning implementation of the current OpenCL API.
The other ICD loader libraries are installed as part of each vendor's SDK. If you want to ensure the ICD loader from the
/etc/ld.so.conf.d which adds
/usr/lib to the dynamic program loader's search directories:
This is necessary because all the SDKs add their runtime's lib directories to the search path through
The available packages containing various OpenCL ICDs are:
- : recommended, most up-to-date
- AUR by AMD. Provides OpenCL 2.0. It is distributed by AMD under a restrictive license and therefore cannot be included into the official repositories.
- AUR by Intel. Provides OpenCL 2.0, deprecated in favour of .
For OpenCL development, the bare minimum additional packages required, are:
- : OpenCL ICD loader implementation, up to date with the latest OpenCL specification.
- : OpenCL C/C++ API headers.
The vendors' SDKs provide a multitude of tools and support libraries:
- Intel OpenCL SDK (old version, new OpenCL SDKs are included in the INDE and Intel Media Server Studio) AUR:
/opt/AMDAPPand apart from SDK files it also contains a number of code samples (
/opt/AMDAPP/SDK/samples/). It also provides the
clinfoutility which lists OpenCL platforms and devices present in the system and displays detailed information about them. As AMD APP SDK itself contains CPU OpenCL driver, no extra driver is needed to execute OpenCL on CPU devices (regardless of its vendor). GPU OpenCL drivers are provided by the AUR package (an optional dependency).
AUR: This package is installed as
- : Nvidia's GPU SDK which includes support for OpenCL 1.1.
To see which OpenCL implementations are currently active on your system, use the following command:
$ ls /etc/OpenCL/vendors
To find out all possible (known) properties of the OpenCL platform and devices available on the system, install .
- D: cl4d
- Java: JOCL (a part of JogAmp)
- Mono/.NET: Open Toolkit
- Go: OpenCL bindings for Go
- Racket: Racket has a native interface on PLaneT that can be installed via raco.
- Rust: ocl
- Julia: OpenCL.jl
SYCL is another open and royalty-free standard by the Khronos Group that defines a single-source heterogeneous programming model for C++ on top of OpenCL 1.2.
SYCL consists of a runtime part and a C++ device compiler. The device compiler may target any number and kind of accelerators. The runtime is required to fall back to a pure CPU code path in case no OpenCL implementation can be found.
- AUR Codeplay's proprietary implementation of SYCL 1.2.1. Can target SPIR, SPIR-V and experimentally PTX (NVIDIA) as device targets.
- AUR: Open source implementation mainly driven by Xilinx.
- AUR and AUR: Free implementation built over AMD's HIP instead of OpenCL. Is able to run on AMD and NVIDIA GPUs.
Checking For SPIR Support
Most SYCL implementations are able to compile the accelerator code to SPIR or SPIR-V. Both are intermediate languages designed by Khronos that can be consumed by an OpenCL driver. To check whether SPIR or SPIR-V are supported can be used:
$ clinfo | grep -i spir
Platform Extensions cl_khr_icd cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_depth_images cl_khr_3d_image_writes cl_intel_exec_by_local_thread cl_khr_spir cl_khr_fp64 cl_khr_image2d_from_buffer cl_intel_vec_len_hint IL version SPIR-V_1.0 SPIR versions 1.2
ComputeCpp additionally ships with a tool that summarizes the relevant system information:
Device 0: Device is supported : UNTESTED - Untested OS CL_DEVICE_NAME : Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz CL_DEVICE_VENDOR : Intel(R) Corporation CL_DRIVER_VERSION : 18.1.0.0920 CL_DEVICE_TYPE : CL_DEVICE_TYPE_CPU
Drivers known to at least partially support SPIR or SPIR-V include, AUR, AUR and AUR.
SYCL requires a working C++11 environment to be set up. There are a few open source libraries available:
- ComputeCpp SDK: Collection of code examples, integration for ComputeCpp
- SYCL-DNN: Neural network performance primitives
- SYCL-BLAS: Linear algebra performance primitives
- VisionCpp: Computer Vision library
- SYCL Parallel STL: GPU implementation of the C++17 parallel algorithms
- proprietary Nvidia kernel module
- CUDA "driver" and "runtime" libraries
- additional libraries: CUBLAS, CUFFT, CUSPARSE, etc.
- CUDA toolkit, including the
- CUDA SDK, which contains many code samples and examples of CUDA and OpenCL programs
/opt/cuda. For compiling CUDA code, add
/opt/cuda/include to your include path in the compiler instructions. For example this can be accomplished by adding
-I/opt/cuda/include to the compiler flags/options. To use
gcc wrapper provided by NVIDIA, just add
/opt/cuda/bin to your path.
To find whether the installation was successful and if cuda is up and running, you can compile the samples installed on
/opt/cuda/samples (you can simply run
make inside the directory, altough is a good practice to copy the
/opt/cuda/samples directory to your home directory before compiling) and running the compiled examples. A nice way to check the installation is to run one of the examples, called
- Fortran: PGI CUDA Fortran Compiler
- Haskell: The accelerate package lists available CUDA backends
- Java: JCuda
- Mathematica: CUDAlink
- Mono/.NET: CUDA.NET, CUDAfy.NET
- Perl: KappaCUDA, CUDA-Minimal
- Python: or Kappa
- Ruby, Lua: Kappa
List of GPGPU accelerated software
- Blender – CUDA support for Nvidia GPUs and OpenCL support for AMD GPUs. More information here.
- FFmpeg – more information here.
- GIMP – experimental – more information here.
- LibreOffice Calc – more information here.
- – Find all possible (known) properties of the OpenCL platform and devices available on the system.
- AUR – a GPU memtest. Despite its name, is supports both CUDA and OpenCL.
- AUR - a non-linear video editor. Can use both OpenCL and CUDA.
- – OpenCL feature requires at least 1 GB RAM on GPU and Image support (check output of clinfo command).
- - Port of TensorFlow to CUDA
- AUR - Port of TensorFlow to SYCL