GPGPU
GPGPU stands for General-purpose computing on graphics processing units. In Linux, there are currently two major GPGPU frameworks: OpenCL and CUDA.
Contents
OpenCL
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.
OpenCL Runtime
To execute programs that use OpenCL, a compatible hardware runtime needs to be installed.
AMD/ATI
- opencl-mesa: free runtime for AMDGPU and Radeon
- opencl-amdAUR: proprietary standalone runtime for AMDGPU
- amdgpu-pro-openclAUR: proprietary runtime for AMDGPU PRO
- opencl-catalystAUR: AMD proprietary runtime, soon to be deprecated in favor of AMDGPU
- amdapp-sdkAUR: AMD CPU runtime
NVIDIA
- opencl-nvidia: official NVIDIA runtime
Intel
- compute-runtimeAUR or compute-runtime-binAUR: a.k.a. the Neo OpenCL runtime, the open-source implementation for Gen8 (Broadwell) and beyond.
- beignet: the open-source implementation for Gen7 (Ivy Bridge) and beyond, deprecated by Intel in favor of NEO OpenCL driver, remains recommended solution for legacy HW platforms (e.g. Ivy Bridge, Sandy Bridge, Haswell).
- intel-opencl-runtimeAUR: the implementation for Intel Core and Xeon processors. It also supports non-Intel CPUs.
Others
- poclAUR: 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 (ocl-icd) 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 ocl-icd package is used, you can create a file in /etc/ld.so.conf.d
which adds /usr/lib
to the dynamic program loader's search directories:
/etc/ld.so.conf.d/00-usrlib.conf
/usr/lib
This is necessary because all the SDKs add their runtime's lib directories to the search path through ld.so.conf.d
files.
The available packages containing various OpenCL ICDs are:
- ocl-icd: recommended, most up-to-date
- libopenclAUR by AMD. Provides OpenCL 2.0. It is distributed by AMD under a restrictive license and therefore cannot be included into the official repositories.
- intel-openclAUR by Intel. Provides OpenCL 2.0, deprecated in favour of compute-runtimeAUR.
OpenCL Development
For OpenCL development, the bare minimum additional packages required, are:
- ocl-icd: OpenCL ICD loader implementation, up to date with the latest OpenCL specification.
- opencl-headers: OpenCL C/C++ API headers.
The vendors' SDKs provide a multitude of tools and support libraries:
- intel-opencl-sdkAUR: Intel OpenCL SDK (old version, new OpenCL SDKs are included in the INDE and Intel Media Server Studio)
-
amdapp-sdkAUR: This package is installed as
/opt/AMDAPP
and apart from SDK files it also contains a number of code samples (/opt/AMDAPP/SDK/samples/
). It also provides theclinfo
utility 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 catalystAUR package (an optional dependency). - cuda: Nvidia's GPU SDK which includes support for OpenCL 1.1.
Implementations
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 clinfo.
Language bindings
- JavaScript/HTML5: WebCL
- Python: python-pyopencl
- 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
CUDA
CUDA (Compute Unified Device Architecture) is NVIDIA's proprietary, closed-source parallel computing architecture and framework. It requires a Nvidia GPU. It consists of several components:
- required:
- proprietary Nvidia kernel module
- CUDA "driver" and "runtime" libraries
- optional:
- additional libraries: CUBLAS, CUFFT, CUSPARSE, etc.
- CUDA toolkit, including the
nvcc
compiler - CUDA SDK, which contains many code samples and examples of CUDA and OpenCL programs
The kernel module and CUDA "driver" library are shipped in nvidia and opencl-nvidia. The "runtime" library and the rest of the CUDA toolkit are available in cuda. The library is available only in 64-bit version. cuda-gdb
needs ncurses5-compat-libsAUR to be installed, see FS#46598.
Development
The cuda package installs all components in the directory /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 nvcc
, a 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 deviceQuery
.
/opt/cuda/bin/
for the older version to be picked up by nvcc
. You might also need to configure your build system to use the same GCC version for compiling host code. Check the release notes for a list of compilers supported as host compilers.Language bindings
- 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: python-pycuda or Kappa
- Ruby, Lua: Kappa
List of GPGPU accelerated software
- clinfo – Find all possible (known) properties of the OpenCL platform and devices available on the system.
- Bitcoin
- Blender – CUDA support for Nvidia GPUs and OpenCL support for AMD GPUs. More information here.
- BOINC
- cuda_memtestAUR – a GPU memtest. Despite its name, is supports both CUDA and OpenCL.
- darktable – OpenCL feature requires at least 1 GB RAM on GPU and Image support (check output of clinfo command).
- GIMP – experimental – more information here.
- HandBrake
- Hashcat
- imagemagick
- LibreOffice Calc – more information here.
- opencv
- pyrit
- davinci-resolveAUR - a non-linear video editor. Can use both OpenCL and CUDA.