Difference between revisions of "GPGPU"

From ArchWiki
Jump to: navigation, search
(CUDA: added note about 304xx driver and multi-gpu systems)
(OpenCL: add info about amdgpu-pro)
 
(68 intermediate revisions by 25 users not shown)
Line 1: Line 1:
 
[[Category:Development]]
 
[[Category:Development]]
 
[[Category:Graphics]]
 
[[Category:Graphics]]
{{Out of date|With new versions of OpenCL, the things have changed a little bit.}}
+
[[ja:GPGPU]]
{{Article summary start}}
+
{{Related articles start}}
{{Article summary text|Installation and usage of OpenCL and CUDA, the two major Linux GPGPU frameworks}}
+
{{Related|Catalyst}}
{{Article summary heading|Related}}
+
{{Related|Nvidia}}
{{Article summary wiki|Catalyst}}
+
{{Related articles end}}
{{Article summary wiki|Nvidia}}
+
{{Article summary end}}
+
  
GPGPU stands for [http://en.wikipedia.org/wiki/Gpgpu General-purpose computing on graphics processing units].
+
GPGPU stands for [[Wikipedia:GPGPU|General-purpose computing on graphics processing units]].
In Linux, there are currently two major GPGPU frameworks: [http://en.wikipedia.org/wiki/OpenCL OpenCL] and [http://en.wikipedia.org/wiki/CUDA CUDA]<br><br>
+
In Linux, there are currently two major GPGPU frameworks: [[Wikipedia:OpenCL|OpenCL]] and [[Wikipedia:CUDA|CUDA]]
  
 
==OpenCL==
 
==OpenCL==
===Overview===
 
OpenCL (Open Computing Language) is an open, royalty-free parallel programming framework developed by the Khronos Group, a non-profit consortium.
 
  
Distribution of the OpenCL framework generally consists of:
+
OpenCL (Open Computing Language) is an open, royalty-free parallel programming specification developed by the Khronos Group, a non-profit consortium.
* Library providing OpenCL API, known as libCL or libOpenCL ({{ic|libOpenCL.so}} in linux)
+
* OpenCL implementation(s), which contain:
+
** Device drivers
+
** OpenCL/C code compiler
+
** SDK *
+
* Header files *
+
''* only needed for development''
+
  
===OpenCL library===
+
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.
There are several choices for the libCL. In general case, installing {{Pkg|libcl}} from [extra] should do :
+
# pacman -S libcl
+
However, there are situations when another libCL distribution is more suitable. The following paragraph covers this more advanced topic.
+
  
===The OpenCL ICD model===
+
Arch Linux provides multiple packages for all of these.
OpenCL offers the option to install multiple vendor-specific implementations on the same machine at the same time.
+
In practice, this is implemented using the Installable Client Driver (ICD) model.
+
The center point of this model is the libCL library which in fact imeplements ICD Loader.
+
Through the ICD Loader, an OpenCL application is able to access all platforms and all devices present in the system.
+
  
Although itself vendor-agnostic, the ICD Loader still has to be provided by someone. In Archlinux, there are currently two options:
+
To '''execute''' programs that use OpenCL, you need to install a runtime compatible with your hardware:
* extra/{{Pkg|libcl}} by Nvidia. Provides OpenCL version 1.0 and is thus slightly outdated. Its behaviour with OpenCL 1.1 code has not been tested as of yet.
+
* {{Pkg|opencl-nvidia}}: execute on your Nvidia GPU (official Nvidia runtime)
* unsupported/{{AUR|libopencl}} by AMD. Provides up to date version 1.1 of OpenCL. It is currently distributed by AMD under a restrictive license and therefore could not have been pushed into official repo.
+
* {{Pkg|opencl-mesa}}: execute on AMD GPU's using the mesa drivers (currently under development, your mileage may vary)
 +
* {{AUR|opencl-catalyst}}: execute on your AMD GPU (official AMD runtime, soon to be deprecated)
 +
* {{AUR|amdgpu-pro-computing}}: execute on your AMD GPU (official AMD runtime, auto-generated from Ubuntu package)
 +
* {{AUR|intel-opencl-runtime}}: execute on your CPU (official Intel runtime, also supports non-Intel CPUs)
 +
* {{AUR|pocl}}: execute on your CPU (LLVM-based OpenCL implementation)
  
(There is also Intel's libCL, this one is currently not provided in a separate package though.)
+
For OpenCL '''development''', the bare minimum additional packages required, are:
 +
* {{Pkg|ocl-icd}}: OpenCL ICD loader implementation, up to date with the latest OpenCL specification.
 +
* {{Pkg|opencl-headers}}: OpenCL C/C++ API headers.
  
{{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<br>(as long as they are implemented correctly)}}
+
The vendors' SDKs provide a multitude of tools and support libraries:
 +
* {{AUR|intel-opencl-sdk}}: Intel's OpenCL SDK (old version, new OpenCL SDKs are included in the INDE and Intel Media Server Studio)
 +
* {{AUR|amdapp-sdk}}: AMD's OpenCL SDK
 +
* {{Pkg|cuda}}: Nvidia's GPU SDK which includes support for OpenCL 1.1.
  
For basic usage, extra/libcl is recommended as its installation and updating is convenient. For advanced usage, libopencl is recommended. Both libcl and libopencl should still work with all the implementations.
+
===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 ({{Pkg|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 {{Pkg|ocl-icd}} package is used, you can create a file in {{ic|/etc/ld.so.conf.d}} which adds {{ic|/usr/lib}} to the dynamic program loader's search directories:
 +
 
 +
{{hc|/etc/ld.so.conf.d/00-usrlib.conf|2=<nowiki>
 +
/usr/lib</nowiki>}}
 +
 
 +
This is necessary because all the SDKs add their runtime's lib directories to the search path through {{ic|ld.so.conf.d}} files.
 +
 
 +
The available packages containing various OpenCL ICDs are:
 +
* {{Pkg|ocl-icd}}: recommended, most up-to-date
 +
* {{AUR|libopencl}} by AMD. Provides version 2.0 of OpenCL. It is currently distributed by AMD under a restrictive license and therefore could not have been pushed into official repo.
 +
* {{AUR|intel-opencl-runtime}}: Intel's libCL, provides OpenCL 1.2.
 +
 
 +
{{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)}}
  
 
===Implementations===
 
===Implementations===
 
To see which OpenCL implementations are currently active on your system, use the following command:
 
To see which OpenCL implementations are currently active on your system, use the following command:
{{bc|$ ls /etc/OpenCL/vendors}}
+
$ ls /etc/OpenCL/vendors
  
 
====AMD====
 
====AMD====
 
OpenCL implementation from AMD is known as [http://developer.amd.com/sdks/AMDAPPSDK/Pages/default.aspx AMD APP SDK], formerly also known as AMD Stream SDK or ATi Stream.
 
OpenCL implementation from AMD is known as [http://developer.amd.com/sdks/AMDAPPSDK/Pages/default.aspx AMD APP SDK], formerly also known as AMD Stream SDK or ATi Stream.
  
For Arch Linux, AMD APP SDK is currently available in AUR as {{AUR|amdstream}}.
+
It can be installed with the {{AUR|amdapp-sdk}} package.  
This package is installed as {{ic|/opt/amdstream}} and apart from SDK files it also contains a profiler ({{ic|/opt/amdstream/bin/sprofile}}) and a number of code samples ({{ic|/opt/amdstream/samples/opencl}}). It also provides the {{ic|clinfo}} utility which lists OpenCL platforms and devices present in the system and displays detailed information about them.
+
This package is installed as {{ic|/opt/AMDAPP}} and apart from SDK files it also contains a number of code samples ({{ic|/opt/AMDAPP/SDK/samples/}}). It also provides the {{ic|clinfo}} 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 use execute OpenCL on CPU devices (regardless of its vendor). GPU OpenCL drivers are provided by the {{AUR|catalyst}} package (an optional dependency), the open-source driver ({{Pkg|xf86-video-ati}}) does ''not'' support OpenCL.
+
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|catalyst}} package (an optional dependency).
  
 
Code is compiled using {{Pkg|llvm}} (dependency).
 
Code is compiled using {{Pkg|llvm}} (dependency).
 +
 +
====Mesa (Gallium)====
 +
{{Out of date|How accurate is this part?}}
 +
OpenCL support from Mesa is in development (see http://www.x.org/wiki/GalliumStatus/). AMD Radeon cards are supported by the r600g driver.
 +
 +
Arch Linux ships OpenCL support as a separate package {{Pkg|opencl-mesa}}. See http://dri.freedesktop.org/wiki/GalliumCompute/ for usage instructions.
 +
 +
You could also use [http://pkgbuild.com/~lcarlier/mesa-git/ lordheavy's repo]. Install these packages:
 +
* ati-dri-git
 +
* opencl-mesa-git
 +
* libclc-git
 +
 +
Surprisingly, pyrit performs 20% better with radeon+r600g compared to Catalyst 13.11 Beta1 (tested with 7 other CPU cores):
 +
{{bc|<nowiki>catalyst    #1: 'OpenCL-Device 'Barts'': 21840.7 PMKs/s (RTT 2.8)
 +
radeon+r600g #1: 'OpenCL-Device 'AMD BARTS'': 26608.1 PMKs/s (RTT 3.0)</nowiki>}}
 +
At the time of this writing (30 October 2013), one must apply patches [http://people.freedesktop.org/~tstellar/pyrit-perf/0001-XXX-clover-Calculate-the-optimal-work-group-size.patch] and [http://people.freedesktop.org/~tstellar/pyrit-perf/0001-radeon-llvm-Specify-the-DataLayout-when-running-opti.patch] on top of Mesa commit ac81b6f2be8779022e8641984b09118b57263128 to get this performance improvement. The latest unpatched LLVM trunk was used (SVN rev 193660).
  
 
====Nvidia====
 
====Nvidia====
The Nvidia implementation is available in extra/{{Pkg|opencl-nvidia}}. It only supports Nvidia GPUs running the {{Pkg|nvidia}} kernel module (nouveau does not support OpenCL yet).
+
The Nvidia implementation is available as {{Pkg|opencl-nvidia}} from the [[official repositories]]. It only supports Nvidia GPUs running the {{Pkg|nvidia}} kernel module (nouveau does not support OpenCL yet).
  
 
====Intel====
 
====Intel====
 
The Intel implementation, named simply [http://software.intel.com/en-us/articles/opencl-sdk/ Intel OpenCL SDK],  
 
The Intel implementation, named simply [http://software.intel.com/en-us/articles/opencl-sdk/ Intel OpenCL SDK],  
provides optimized OpenCL performance on Intel CPUs (mainly Core and Xeon) and CPUs only. There is no GPU support as Intel GPUs do not support OpenCL/GPGPU. Package is available in AUR: {{AUR|intel-opencl-sdk}}.
+
provides optimized OpenCL performance on Intel CPUs (mainly Core and Xeon) and CPUs only. Install it with the {{AUR|intel-opencl-sdk}} package. The runtime can be installed with the separate {{AUR|intel-opencl-runtime}} package. OpenCL for integrated graphics hardware is available through the {{AUR|beignet}} package for Ivy Bridge and newer hardware.
 +
 
 +
====POCL====
 +
CPU-only LLVM-based implementation. Available as {{AUR|pocl}}.
  
 
===Development===
 
===Development===
For development of OpenCL-capable applications, full installation of the OpenCL framework including implementation, drivers and compiler plus the {{Pkg|opencl-headers}} package is needed. Link your code against {{ic|libOpenCL}}.
+
 
 +
The required packages for OpenCL development are listed in the overview. Installation of a full SDK is optional (depending on the runtime implementation, which is often only available as part of a vendor's SDK).
 +
Link your application to {{ic|libOpenCL.so}}.
  
 
====Language bindings====
 
====Language bindings====
* '''C++''': A binding by Khronos is part of the official specs. It is included in {{Pkg|opencl-headers}}
 
* '''C++/Qt''': An experimental binding named [http://qt.gitorious.org/qt-labs/opencl QtOpenCL] is in Qt Labs - see [http://labs.qt.nokia.com/2010/04/07/using-opencl-with-qt/ Blog entry] for more information
 
 
* '''JavaScript/HTML5''': [http://www.khronos.org/webcl/ WebCL]
 
* '''JavaScript/HTML5''': [http://www.khronos.org/webcl/ WebCL]
* '''[[Python]]''': There are two bindings with the same name: PyOpenCL. One is in [extra]: {{Pkg|python2-pyopencl}}, for the other one see [http://sourceforge.net/projects/pyopencl/ sourceforge]
+
* '''[[Python]]''': {{pkg|python-pyopencl}}
 
* '''[[D]]''': [https://bitbucket.org/trass3r/cl4d/wiki/Home cl4d]
 
* '''[[D]]''': [https://bitbucket.org/trass3r/cl4d/wiki/Home cl4d]
* '''Haskell''': The OpenCLRaw package is available in AUR: {{AUR|haskell-openclraw}}
+
* '''[[Haskell]]''': OpenCLRaw: {{AUR|haskell-openclraw-git}}{{Broken package link|{{aur-mirror|haskell-openclraw-git}}}}
 
* '''[[Java]]''': [http://jogamp.org/jocl/www/ JOCL] (a part of [http://jogamp.org/ JogAmp])
 
* '''[[Java]]''': [http://jogamp.org/jocl/www/ JOCL] (a part of [http://jogamp.org/ JogAmp])
 
* '''[[Mono|Mono/.NET]]''': [http://sourceforge.net/projects/opentk/ Open Toolkit]
 
* '''[[Mono|Mono/.NET]]''': [http://sourceforge.net/projects/opentk/ Open Toolkit]
 +
* '''[[Go]]''': [https://github.com/samuel/go-opencl OpenCL bindings for Go]
 +
* '''Racket''': Racket has a native interface [http://planet.racket-lang.org/display.ss?owner=jaymccarthy&package=opencl.plt on PLaneT] that can be installed via raco.
  
 
==CUDA==
 
==CUDA==
  
CUDA (Compute Unified Device Architecture) is [[Nvidia]]'s proprietary, closed-source parallel computing architecture and framework. It is made of several components:
+
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:
 
* required:
 
** proprietary Nvidia kernel module
 
** proprietary Nvidia kernel module
Line 91: Line 121:
 
** CUDA SDK, which contains many code samples and examples of CUDA and OpenCL programs
 
** CUDA SDK, which contains many code samples and examples of CUDA and OpenCL programs
  
The kernel module and CUDA "driver" library are shipped in extra/{{Pkg|nvidia}} and extra/{{Pkg|opencl-nvidia}}. The "runtime" library and the rest of the CUDA toolkit are available in community/{{Pkg|cuda}}. The SDK has been packaged too ({{AUR|cuda-sdk}}), even if it is not required for developing in CUDA.
+
The kernel module and CUDA "driver" library are shipped in {{Pkg|nvidia}} and {{Pkg|opencl-nvidia}}. The "runtime" library and the rest of the CUDA toolkit are available in {{Pkg|cuda}}. The library is available [https://projects.archlinux.org/svntogit/community.git/commit/trunk?h=packages/cuda&id=1b62c8bcb9194b2de1b750bd62a8dce1e7e549f5 only in 64-bit version].
  
 
===Development===
 
===Development===
  
When installing {{Pkg|cuda}} package you get the directory /opt/cuda created where all of the components "live". 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.
+
The {{Pkg|cuda}} package installs all components in the directory {{ic|/opt/cuda}}. For compiling CUDA code, add {{ic|/opt/cuda/include}} to your include path in the compiler instructions. For example this can be accomplished by adding {{ic|-I/opt/cuda/include}} to the compiler flags/options. To use {{ic|nvcc}}, a {{ic|gcc}} wrapper provided by NVIDIA, just add {{ic|/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 {{ic|/opt/cuda/sample}} (you can simply run {{ic|make}} inside the directory, altough is a good practice to copy the {{ic|/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 {{ic|deviceQuery}}.
 +
 
 +
{{Note|CUDA 7.5/8.0 is not compatible with GCC 6 (see {{Bug|49272}}). Therefore the {{Pkg|cuda}} package depends on {{Pkg|gcc5}} and creates symbolic links in {{ic|/opt/cuda/bin/}} for the older version to be picked up by {{ic|nvcc}}. You might also need to configure your build system to use the same GCC version for compiling host code.}}
  
 
===Language bindings===
 
===Language bindings===
* '''Fortran''': [http://www.hoopoe-cloud.com/Solutions/Fortran/Default.aspx FORTRAN CUDA], [http://www.pgroup.com/resources/cudafortran.htm PGI CUDA Fortran Compiler]
+
* '''Fortran''': [http://www.pgroup.com/resources/cudafortran.htm PGI CUDA Fortran Compiler]
* '''[[Python]]''': In AUR: {{AUR|pycuda}}, also [http://psilambda.com/download/kappa-for-python Kappa]
+
* '''[[Haskell]]''': The [http://hackage.haskell.org/package/accelerate accelerate package] lists available CUDA backends
* '''Perl''': [http://psilambda.com/download/kappa-for-perl Kappa], [https://github.com/run4flat/perl-CUDA-Minimal CUDA-Minimal]
+
* '''[[Java]]''': [http://www.jcuda.org/jcuda/JCuda.html JCuda]
* '''Haskell''': The CUDA package is available in AUR: {{AUR|haskell-cuda}}. There is also [http://hackage.haskell.org/package/accelerate The accelerate package]
+
* '''Java''': [http://www.hoopoe-cloud.com/Solutions/jCUDA/Default.aspx jCUDA], [http://www.jcuda.org/jcuda/JCuda.html JCuda]
+
* '''[[Mono|Mono/.NET]]''': [http://www.hoopoe-cloud.com/Solutions/CUDA.NET/Default.aspx CUDA.NET], [http://www.hybriddsp.com/ CUDAfy.NET]
+
 
* '''[[Mathematica]]''': [http://reference.wolfram.com/mathematica/CUDALink/tutorial/Overview.html CUDAlink]
 
* '''[[Mathematica]]''': [http://reference.wolfram.com/mathematica/CUDALink/tutorial/Overview.html CUDAlink]
 +
* '''[[Mono|Mono/.NET]]''': [http://www.hoopoe-cloud.com/Solutions/CUDA.NET/Default.aspx CUDA.NET], [http://www.hybriddsp.com/ CUDAfy.NET]
 +
* '''Perl''': [http://psilambda.com/download/kappa-for-perl Kappa], [https://github.com/run4flat/perl-CUDA-Minimal CUDA-Minimal]
 +
* '''[[Python]]''': {{pkg|python-pycuda}} or [http://psilambda.com/download/kappa-for-python Kappa]
 
* '''[[Ruby]]''', '''Lua''': [http://psilambda.com/products/kappa/ Kappa]
 
* '''[[Ruby]]''', '''Lua''': [http://psilambda.com/products/kappa/ Kappa]
  
Line 114: Line 148:
 
{{Expansion}}
 
{{Expansion}}
 
* [[Bitcoin]]
 
* [[Bitcoin]]
* [[GIMP]] (development in progress - see [http://www.phoronix.com/scan.php?page=news_item&px=OTc5OQ this notice])
+
* [[GIMP]] (experimental - see [http://www.h-online.com/open/news/item/GIMP-2-8-RC-1-arrives-with-GPU-acceleration-1518417.html])
* {{AUR|Pyrit}}
+
* {{Pkg|pyrit}}
* {{AUR|aircrack-ng}}
+
* {{Pkg|darktable}} - OpenCL feature requires at least 1 GB RAM on GPU and ''Image support'' (check output of clinfo command).
 +
* {{Pkg|aircrack-ng}}
 +
* {{AUR|john-opencl}}{{Broken package link|{{aur-mirror|john-opencl}}}}
 
* {{AUR|cuda_memtest}} - a GPU memtest. Despite its name, is supports both CUDA and OpenCL
 
* {{AUR|cuda_memtest}} - a GPU memtest. Despite its name, is supports both CUDA and OpenCL
 +
* {{Pkg|blender}} - CUDA support for Nvidia GPUs and OpenCL support for AMD GPUs. More information [http://blender.org/manual/render/cycles/features.html#features here].
  
 
==Links and references==
 
==Links and references==
Line 123: Line 160:
 
* [http://www.nvidia.com/object/cuda_home_new.html CUDA official homepage]
 
* [http://www.nvidia.com/object/cuda_home_new.html CUDA official homepage]
 
* [http://www.khronos.org/registry/cl/extensions/khr/cl_khr_icd.txt The ICD extension specification]
 
* [http://www.khronos.org/registry/cl/extensions/khr/cl_khr_icd.txt The ICD extension specification]
* [http://developer.amd.com/sdks/AMDAPPSDK/Pages/default.aspx AMD APP SDK homepage]
+
* [http://developer.amd.com/appsdk AMD APP SDK homepage]
* [http://developer.nvidia.com/cuda-toolkit-40 CUDA Toolkit homepage]
+
* [https://developer.nvidia.com/cuda-toolkit CUDA Toolkit homepage]
* [http://software.intel.com/en-us/articles/opencl-sdk/ Intel OpenCL SDK homepage]
+
* [https://software.intel.com/en-us/intel-opencl Intel SDK for OpenCL Applications homepage]

Latest revision as of 18:20, 1 December 2016

Related articles

GPGPU stands for General-purpose computing on graphics processing units. In Linux, there are currently two major GPGPU frameworks: OpenCL and CUDA

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.

Arch Linux provides multiple packages for all of these.

To execute programs that use OpenCL, you need to install a runtime compatible with your hardware:

  • opencl-nvidia: execute on your Nvidia GPU (official Nvidia runtime)
  • opencl-mesa: execute on AMD GPU's using the mesa drivers (currently under development, your mileage may vary)
  • opencl-catalystAUR: execute on your AMD GPU (official AMD runtime, soon to be deprecated)
  • amdgpu-pro-computingAUR: execute on your AMD GPU (official AMD runtime, auto-generated from Ubuntu package)
  • intel-opencl-runtimeAUR: execute on your CPU (official Intel runtime, also supports non-Intel CPUs)
  • poclAUR: execute on your CPU (LLVM-based OpenCL implementation)

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's OpenCL SDK (old version, new OpenCL SDKs are included in the INDE and Intel Media Server Studio)
  • amdapp-sdkAUR: AMD's OpenCL SDK
  • cuda: Nvidia's GPU SDK which includes support for OpenCL 1.1.

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 version 2.0 of OpenCL. It is currently distributed by AMD under a restrictive license and therefore could not have been pushed into official repo.
  • intel-opencl-runtimeAUR: Intel's libCL, provides OpenCL 1.2.
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)

Implementations

To see which OpenCL implementations are currently active on your system, use the following command:

$ ls /etc/OpenCL/vendors

AMD

OpenCL implementation from AMD is known as AMD APP SDK, formerly also known as AMD Stream SDK or ATi Stream.

It can be installed with the amdapp-sdkAUR package. 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 the clinfo 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).

Code is compiled using llvm (dependency).

Mesa (Gallium)

Tango-view-refresh-red.pngThis article or section is out of date.Tango-view-refresh-red.png

Reason: How accurate is this part? (Discuss in Talk:GPGPU#)

OpenCL support from Mesa is in development (see http://www.x.org/wiki/GalliumStatus/). AMD Radeon cards are supported by the r600g driver.

Arch Linux ships OpenCL support as a separate package opencl-mesa. See http://dri.freedesktop.org/wiki/GalliumCompute/ for usage instructions.

You could also use lordheavy's repo. Install these packages:

  • ati-dri-git
  • opencl-mesa-git
  • libclc-git

Surprisingly, pyrit performs 20% better with radeon+r600g compared to Catalyst 13.11 Beta1 (tested with 7 other CPU cores):

catalyst     #1: 'OpenCL-Device 'Barts'': 21840.7 PMKs/s (RTT 2.8)
radeon+r600g #1: 'OpenCL-Device 'AMD BARTS'': 26608.1 PMKs/s (RTT 3.0)

At the time of this writing (30 October 2013), one must apply patches [1] and [2] on top of Mesa commit ac81b6f2be8779022e8641984b09118b57263128 to get this performance improvement. The latest unpatched LLVM trunk was used (SVN rev 193660).

Nvidia

The Nvidia implementation is available as opencl-nvidia from the official repositories. It only supports Nvidia GPUs running the nvidia kernel module (nouveau does not support OpenCL yet).

Intel

The Intel implementation, named simply Intel OpenCL SDK, provides optimized OpenCL performance on Intel CPUs (mainly Core and Xeon) and CPUs only. Install it with the intel-opencl-sdkAUR package. The runtime can be installed with the separate intel-opencl-runtimeAUR package. OpenCL for integrated graphics hardware is available through the beignetAUR package for Ivy Bridge and newer hardware.

POCL

CPU-only LLVM-based implementation. Available as poclAUR.

Development

The required packages for OpenCL development are listed in the overview. Installation of a full SDK is optional (depending on the runtime implementation, which is often only available as part of a vendor's SDK). Link your application to libOpenCL.so.

Language bindings

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.

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/sample (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.

Note: CUDA 7.5/8.0 is not compatible with GCC 6 (see FS#49272). Therefore the cuda package depends on gcc5 and creates symbolic links in /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.

Language bindings

Driver issues

It might be necessary to use the legacy driver nvidia-304xx or nvidia-304xx-lts to resolve permissions issues when running CUDA programs on systems with multiple GPUs.

List of OpenCL and CUDA accelerated software

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: please use the first argument of the template to provide a brief explanation. (Discuss in Talk:GPGPU#)

Links and references