GPGPU

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.

Tip: The clinfo utility can be used to list OpenCL platforms, devices present and ICD loader properties.

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: ROCr OpenCL and legacy OpenCL (a.k.a. orca) repackaged from AMD's ubuntu releases
  • rocm-opencl-runtimeAUR: Part of AMD's ROCm GPU compute stack, officially supporting GFX8 and later cards (Fiji, Polaris, Vega), with unofficial and partial support for Navi10 based cards.
  • amdapp-sdkAUR: AMD CPU runtime

NVIDIA

Intel

  • : 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 hardware platforms (e.g. Ivy Bridge, Haswell).
  • : 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 hardware platforms (e.g. Ivy Bridge, Haswell).
  • : the implementation for Intel Core and Xeon processors. It also supports non-Intel CPUs.

Others

  • : LLVM-based OpenCL implementation (hardware independent)

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 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 files.

The available packages containing various OpenCL ICDs are:

  • ocl-icd: recommended, most up-to-date
  • by Intel. Provides OpenCL 2.0, deprecated in favour of .
Note: ICD Loader's vendor is mentioned only to identify each loader, it is otherwise completely irrelevant. ICD loaders are vendor-agnostic and may be used interchangeably (as long as they are implemented correctly).

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 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)
  • amdapp-sdkAUR: This package is installed as and apart from SDK files it also contains a number of code samples (). It also provides the utility which lists OpenCL platforms and devices present in the system and displays detailed information about them. As the SDK itself contains a CPU OpenCL driver, no extra driver is needed to execute OpenCL on CPU devices (regardless of its vendor).
  • : 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 .

Language bindings

SYCL

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.

Implementations

  • Codeplay's proprietary implementation of SYCL 1.2.1. Can target SPIR, SPIR-V and experimentally PTX (NVIDIA) as device targets.
  • : Open source implementation mainly driven by Xilinx.
  • and : 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:

ComputeCpp additionally ships with a tool that summarizes the relevant system information:

Drivers known to at least partially support SPIR or SPIR-V include , , and amdgpu-pro-openclAUR.

SYCL Development

SYCL requires a working C++11 environment to be set up. There are a few open source libraries available:

CUDA

CUDA (Compute Unified Device Architecture) is NVIDIA's proprietary, closed-source parallel computing architecture and framework. It requires an NVIDIA GPU, and 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 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 . needs to be installed, see .

Development

The package installs all components in the directory . For compiling CUDA code, add to your include path in the compiler instructions. For example, this can be accomplished by adding to the compiler flags/options. To use , a gcc wrapper provided by NVIDIA, add to your path.

To find whether the installation was successful and whether CUDA is up and running, you can compile the CUDA samples. One way to check the installation is to run the sample.

Language bindings

ROCm

ROCm (Radeon Open Compute) is AMD's open-source parallel computing architecture and framework. Although it requires an AMD GPU some ROCm tools are hardware agnostic. See the ROCm for Arch Linux repository for more information and installation instructions.

OpenCL Image Support

The latest ROCm versions now includes OpenCL Image Support used by GPGPU accelerated software such as Darktable. ROCm with the AMDGPU open source graphics driver are all that is required. AMDGPU PRO is not required.

List of GPGPU accelerated software

  • Bitcoin
  • Blender – CUDA support for Nvidia GPUs and OpenCL support for AMD GPUs. More information here.
  • BOINC
  • FFmpeg – more information here.
  • Folding@home
  • GIMP – experimental – more information here.
  • HandBrake
  • Hashcat
  • LibreOffice Calc – more information here.
  • clinfo – Find all possible (known) properties of the OpenCL platform and devices available on the system.
  • – a GPU memtest. Despite its name, is supports both CUDA and OpenCL.
  • – OpenCL feature requires at least 1 GB RAM on GPU and Image support (check output of clinfo command).
  • DaVinci Resolve - a non-linear video editor. Can use both OpenCL and CUDA.
  • - Used for searching the neural network (supports tensorflow, OpenCL, CUDA, and openblas)
  • pyritAUR
  • - PyTorch with CUDA backend
  • - Port of TensorFlow to CUDA
  • - Port of TensorFlow to SYCL
  • - High Perf CryptoNote CPU and GPU (OpenCL, CUDA) miner
This article is issued from Archlinux. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.