https://wiki.archlinux.org/api.php?action=feedcontributions&user=Mmha&feedformat=atomArchWiki - User contributions [en]2024-03-28T11:42:55ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=GPGPU&diff=571611GPGPU2019-04-20T03:32:42Z<p>Mmha: Add section on SYCL since the 3 biggest implementations are on AUR now.</p>
<hr />
<div>[[Category:Development]]<br />
[[Category:Graphics]]<br />
[[ja:GPGPU]]<br />
{{Related articles start}}<br />
{{Related|Catalyst}}<br />
{{Related|Nvidia}}<br />
{{Related|Hardware video acceleration}}<br />
{{Related articles end}}<br />
<br />
GPGPU stands for [[Wikipedia:GPGPU|General-purpose computing on graphics processing units]].<br />
In Linux, there are currently two major GPGPU frameworks: [[Wikipedia:OpenCL|OpenCL]] and [[Wikipedia:CUDA|CUDA]].<br />
<br />
==OpenCL==<br />
<br />
OpenCL (Open Computing Language) is an open, royalty-free parallel programming specification developed by the Khronos Group, a non-profit consortium.<br />
<br />
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.<br />
<br />
{{Tip|The {{pkg|clinfo}} utility can be used to list OpenCL platforms, devices present and ICD loader properties.}}<br />
<br />
===OpenCL Runtime===<br />
To '''execute''' programs that use OpenCL, a compatible hardware runtime needs to be installed.<br />
<br />
====AMD/ATI====<br />
* {{Pkg|opencl-mesa}}: free runtime for [[AMDGPU]] and [[Radeon]]<br />
* {{AUR|opencl-amd}}: proprietary standalone runtime for [[AMDGPU]]<br />
* {{AUR|amdgpu-pro-opencl}}: proprietary runtime for [[AMDGPU PRO]]<br />
* {{AUR|opencl-catalyst}}: AMD proprietary runtime, soon to be deprecated in favor of [[AMDGPU]]<br />
* {{AUR|amdapp-sdk}}: AMD CPU runtime<br />
<br />
====NVIDIA====<br />
* {{Pkg|opencl-nvidia}}: official [[NVIDIA]] runtime<br />
<br />
====Intel====<br />
* {{pkg|intel-compute-runtime}}: a.k.a. the Neo OpenCL runtime, the open-source implementation for Intel HD Graphics GPU on Gen8 (Broadwell) and beyond.<br />
* {{pkg|beignet}}: 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).<br />
* {{AUR|intel-opencl}}: 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).<br />
* {{AUR|intel-opencl-runtime}}: the implementation for Intel Core and Xeon processors. It also supports non-Intel CPUs.<br />
<br />
====Others====<br />
* {{AUR|pocl}}: LLVM-based OpenCL implementation<br />
<br />
===OpenCL ICD loader (libOpenCL.so)===<br />
<br />
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.<br />
Most OpenCL vendors provide their own implementation of an OpenCL ICD loader, and these should all work with the other vendors' OpenCL implementations.<br />
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.<br />
<br />
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:<br />
<br />
{{hc|/etc/ld.so.conf.d/00-usrlib.conf|2=<nowiki><br />
/usr/lib</nowiki>}}<br />
<br />
This is necessary because all the SDKs add their runtime's lib directories to the search path through {{ic|ld.so.conf.d}} files.<br />
<br />
The available packages containing various OpenCL ICDs are:<br />
* {{Pkg|ocl-icd}}: recommended, most up-to-date<br />
* {{AUR|libopencl}} by AMD. Provides OpenCL 2.0. It is distributed by AMD under a restrictive license and therefore cannot be included into the official repositories.<br />
* {{AUR|intel-opencl}} by Intel. Provides OpenCL 2.0, deprecated in favour of {{pkg|intel-compute-runtime}}.<br />
<br />
{{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).}}<br />
<br />
===OpenCL Development===<br />
For OpenCL '''development''', the bare minimum additional packages required, are:<br />
* {{Pkg|ocl-icd}}: OpenCL ICD loader implementation, up to date with the latest OpenCL specification.<br />
* {{Pkg|opencl-headers}}: OpenCL C/C++ API headers.<br />
<br />
The vendors' SDKs provide a multitude of tools and support libraries:<br />
* {{AUR|intel-opencl-sdk}}: [http://software.intel.com/en-us/articles/opencl-sdk/ Intel OpenCL SDK] (old version, new OpenCL SDKs are included in the INDE and Intel Media Server Studio)<br />
* {{AUR|amdapp-sdk}}: 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 [http://developer.amd.com/sdks/AMDAPPSDK/Pages/default.aspx 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).<br />
* {{Pkg|cuda}}: Nvidia's GPU SDK which includes support for OpenCL 1.1.<br />
<br />
===Implementations===<br />
To see which OpenCL implementations are currently active on your system, use the following command:<br />
$ ls /etc/OpenCL/vendors<br />
<br />
To find out all possible (known) properties of the OpenCL platform and devices available on the system, [[install]] {{pkg|clinfo}}.<br />
<br />
====Language bindings====<br />
* '''JavaScript/HTML5''': [http://www.khronos.org/webcl/ WebCL]<br />
* '''[[Python]]''': {{pkg|python-pyopencl}}<br />
* '''[[D]]''': [https://bitbucket.org/trass3r/cl4d/wiki/Home cl4d]<br />
* '''[[Java]]''': [http://jogamp.org/jocl/www/ JOCL] (a part of [http://jogamp.org/ JogAmp])<br />
* '''[[Mono|Mono/.NET]]''': [http://sourceforge.net/projects/opentk/ Open Toolkit]<br />
* '''[[Go]]''': [https://github.com/samuel/go-opencl OpenCL bindings for Go]<br />
* '''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.<br />
* '''[[Rust]]''': [https://github.com/cogciprocate/ocl ocl]<br />
* '''[[Julia]]''': [https://github.com/JuliaGPU/OpenCL.jl OpenCL.jl]<br />
<br />
==SYCL==<br />
[[Wikipedia: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.<br />
<br />
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.<br />
<br />
===Implementations===<br />
* {{AUR|computecpp}} Codeplay's proprietary implementation of SYCL 1.2.1. Can target SPIR, SPIR-V and experimentally PTX (NVIDIA) as device targets.<br />
* {{AUR|trisycl-git}}: Open source implementation mainly driven by Xilinx. <br />
* {{AUR|hipsycl-cuda-git}} and {{AUR|hipsycl-rocm-git}}: Free implementation built over AMD's HIP instead of OpenCL. Is able to run on AMD and NVIDIA GPUs.<br />
<br />
===Checking For SPIR Support===<br />
Most SYCL implementations are able to compile the accelerator code to [[Wikipedia:Standard Portable Intermediate Representation|SPIR]] or [[Wikipedia:Standard Portable Intermediate Representation|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 {{pkg|clinfo}} can be used:<br />
<br />
{{hc|head=$ clinfo {{!}} grep -i spir|output=<br />
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 <br />
IL version SPIR-V_1.0<br />
SPIR versions 1.2<br />
}}<br />
<br />
ComputeCpp additionally ships with a tool that summarizes the relevant system information:<br />
{{hc|$ computecpp_info|<br />
Device 0:<br />
<br />
Device is supported : UNTESTED - Untested OS<br />
CL_DEVICE_NAME : Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz<br />
CL_DEVICE_VENDOR : Intel(R) Corporation<br />
CL_DRIVER_VERSION : 18.1.0.0920<br />
CL_DEVICE_TYPE : CL_DEVICE_TYPE_CPU <br />
<br />
}}<br />
<br />
Drivers known to at least partially support SPIR or SPIR-V include {{pkg|intel-compute-runtime}}, {{AUR|intel-opencl-runtime}}, {{AUR|pocl}} and {{AUR|amdgpu-pro-opencl}}.<br />
<br />
===SYCL Development===<br />
SYCL requires a working C++11 environment to be set up. There are a few open source libraries available:<br />
* [https://github.com/codeplaysoftware/computecpp-sdk/ ComputeCpp SDK]: Collection of code examples, {{Pkg|cmake}} integration for ComputeCpp<br />
* [https://github.com/codeplaysoftware/SYCL-DNN SYCL-DNN]: Neural network performance primitives<br />
* [https://github.com/codeplaysoftware/SYCL-BLAS SYCL-BLAS]: Linear algebra performance primitives<br />
* [https://github.com/codeplaysoftware/visioncpp VisionCpp]: Computer Vision library<br />
* [https://github.com/KhronosGroup/SyclParallelSTL SYCL Parallel STL]: GPU implementation of the C++17 parallel algorithms<br />
<br />
==CUDA==<br />
<br />
[[Wikipedia: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:<br />
* required:<br />
** proprietary Nvidia kernel module<br />
** CUDA "driver" and "runtime" libraries<br />
* optional:<br />
** additional libraries: CUBLAS, CUFFT, CUSPARSE, etc.<br />
** CUDA toolkit, including the {{ic|nvcc}} compiler<br />
** CUDA SDK, which contains many code samples and examples of CUDA and OpenCL programs<br />
<br />
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]. {{ic|cuda-gdb}} needs {{aur|ncurses5-compat-libs}} to be installed, see {{Bug|46598}}.<br />
<br />
===Development===<br />
<br />
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.<br />
<br />
To find whether the installation was successful and if cuda is up and running, you can compile the samples installed on {{ic|/opt/cuda/samples}} (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}}.<br />
<br />
===Language bindings===<br />
* '''Fortran''': [http://www.pgroup.com/resources/cudafortran.htm PGI CUDA Fortran Compiler]<br />
* '''[[Haskell]]''': The [http://hackage.haskell.org/package/accelerate accelerate package] lists available CUDA backends <br />
* '''[[Java]]''': [http://www.jcuda.org/jcuda/JCuda.html JCuda]<br />
* '''[[Mathematica]]''': [http://reference.wolfram.com/mathematica/CUDALink/tutorial/Overview.html CUDAlink]<br />
* '''[[Mono|Mono/.NET]]''': [http://www.hoopoe-cloud.com/Solutions/CUDA.NET/Default.aspx CUDA.NET], [http://www.hybriddsp.com/ CUDAfy.NET]<br />
* '''Perl''': [https://metacpan.org/pod/KappaCUDA KappaCUDA], [https://github.com/run4flat/perl-CUDA-Minimal CUDA-Minimal]<br />
* '''[[Python]]''': {{pkg|python-pycuda}} or [http://psilambda.com/download/kappa-for-python Kappa]<br />
* '''[[Ruby]]''', '''Lua''': [http://psilambda.com/products/kappa/ Kappa]<br />
<br />
==List of GPGPU accelerated software==<br />
{{Expansion|More application may support GPGPU.}}<br />
* [[Bitcoin]]<br />
* [[Blender]] – CUDA support for Nvidia GPUs and OpenCL support for AMD GPUs. More information [http://blender.org/manual/render/cycles/features.html#features here].<br />
* [[BOINC]]<br />
* [[FFmpeg]] – more information [https://trac.ffmpeg.org/wiki/HWAccelIntro#OpenCL here].<br />
* [[GIMP]] – experimental – more information [http://www.h-online.com/open/news/item/GIMP-2-8-RC-1-arrives-with-GPU-acceleration-1518417.html here].<br />
* [[HandBrake]]<br />
* [[Hashcat]]<br />
* [[LibreOffice]] Calc – more information [https://help.libreoffice.org/Calc/OpenCL_Options here].<br />
* {{Pkg|clinfo}} – Find all possible (known) properties of the OpenCL platform and devices available on the system.<br />
* {{AUR|cuda_memtest}} – a GPU memtest. Despite its name, is supports both CUDA and OpenCL.<br />
* {{AUR|davinci-resolve}} - a non-linear video editor. Can use both OpenCL and CUDA.<br />
* {{Pkg|darktable}} – OpenCL feature requires at least 1 GB RAM on GPU and ''Image support'' (check output of clinfo command).<br />
* {{Pkg|imagemagick}}<br />
* {{Pkg|opencv}}<br />
* {{Pkg|pyrit}}<br />
* {{Pkg|tensorflow-cuda}} - Port of TensorFlow to CUDA<br />
* {{AUR|tensorflow-computecpp}} - Port of TensorFlow to SYCL<br />
<br />
==Links and references==<br />
* [http://www.khronos.org/opencl/ OpenCL official homepage]<br />
* [https://www.khronos.org/sycl/ SYCL official homepage]<br />
* [https://www.khronos.org/spir/ SPIR official homepage]<br />
* [http://www.nvidia.com/object/cuda_home_new.html CUDA official homepage]<br />
* [http://www.khronos.org/registry/cl/extensions/khr/cl_khr_icd.txt The ICD extension specification]<br />
* [http://developer.amd.com/appsdk AMD APP SDK homepage]<br />
* [https://developer.nvidia.com/cuda-toolkit CUDA Toolkit homepage]<br />
* [https://software.intel.com/en-us/intel-opencl Intel SDK for OpenCL Applications homepage]<br />
* [https://developer.codeplay.com/home/ ComputeCpp official homepage]</div>Mmha