OpenCL

OpenCL is an open framework that enables a computer to recruit all manner of other computational devices (such as a GPU and additional CPUs) to distribute a workload. Depending on the hardware you have available, OpenCL can speed up graphics processing by orders of magnitude.

TL;DR
OpenCL is still a developing technology. If you are building a high performance render farm, it is worth learning and implementing. If you are a regular user doing heavy graphic work, enable OpenCL if it's available to you for some potential benefits, but don't break the bank to to make it happen.

Strengths [Weaknesses]

Parallelism

Your computer potentially has a lot more computing power at its disposal than what you are using. Unlock it with OpenCL.

Weaknesses [Strengths]

Specialised

OpenCL is becoming more common, but for now it is still fairly specialised. Not all applications (or the OS itself, for that matter) utilise OpenCL, and even if they do, OpenCL depends heavily upon the hardware it has available. If your system is not top-of-the-line, you may not see much of a improvement.

Pre-Requisites

Before attempting to get OpenCL up and running, get the specs of your system with cpuinfo and lspci:

$ lspci | grep VGA
[...] NVIDIA [Quadro 5000] (rev c2)

Refer to product documentation to determine whether your GPU is OpenCL capable.

$ egrep sse[3456] /proc/cpuinfo
flags : fpu vme [...] sse3 [...] sse4_1 [...]

If your terminal returns anything, then it is OpenCL capable.

Installing OpenCL

The OpenCL framework consists of an OpenCL library providing the actual API (the programming bits that applications seeking to use OpenCL will actually use), device drivers (to drive the GPU or other OpenCL capable device), and the OpenCL code compiler and header files (needed to build applications with OpenCL enabled).

Here is what you need to do to get them, and to enable them:

Headers

Whether you intend to develop applications using OpenCL or not, in order to build and install OpenCL-capable applications, you need the OpenCL header files.

OpenCL headers are available from http://slackbuilds.org.

OpenCL Library

OpenCL libraries (the .so files in /usr/lib*) mainly come from Nvidia and AMD (other vendors have implementations, but these are the most-used libs, since these are the two most common high-end graphic cards). OpenCL being an open standard, it does not actually matter which library you use. In fact, the OpenCL library you end up with will most likely be dictated by the GPU you have in your computer; the OpenCL library will come along with the driver that you install.

Your OpenCL driver of choice is (ie, libcl or libopencl) loads an Installable Client Driver (defined by an .icd file). The ICD Loader enables an OpenCL application to access all platforms and all devices present in the system, so if you have devices by more than one vendor in your computer (and it's likely that you do), it's to your advantage to define them all.

Therefore, to get the OpenCL library, install a driver for your graphics card and, if available, for your CPU:

  • Nvidia drivers are available from http://slackbuilds.org or directly from Nvidia.
    • AMD drivers, such as they are, are available from http://amd.com.
    • For Intel CPUs and graphic chips, generic drivers come bundled with the Intel Media Server Studio package. This requires registration with Intel and an email verification containing the actual download link. One downloaded, the libraries are located in MediaServerStudioEssentials/SDK20ProductionX.Y*/Generic. For more specific device drivers, see https://software.intel.com/en-us/articles/opencl-drivers.

Installable Client Drivers (ICD)

It's possible to install multiple vendor-specific implementations of OpenCL technology on the same machine, at the same time.

After you have installed your primary OpenCL driver, you should find that an .icd file exists in /etc/OpenCL/vendors/. The contents of the .icd files is straightforward:

$ file /etc/OpenCL/vendors/nvidia.icd
/etc/OpenCL/vendors/nvidia.icd: ASCII text
$ cat /etc/OpenCL/vendors/nvidia.icd
libnvidia-opencl.so.1

It's just a pointer to the vendor library for actual OpenCL functionality.

Install OpenCL drivers for each major vendor whose devices you want to recruit into your OpenCL pool. The common drivers and libraries are:

  • ATI Stream SDK / libatiocl“$ARCH”.so
  • Nvidia / libnvidia-opencl.so
  • Intel / libintelocl.so

Nvidia-modprobe

If you are using a primarily Nvidia environment, you must invoke the nvidia-modprobe command:

As root, open /etc/rc.d/rc.local in a text editor:

$kdesu -c 'emacs /etc/rc.d/rc.local'

And add a line to load in the OpenCL modules.

/usr/bin/nvidia-modprobe -c 0 -u

If you are using AMD or Intel, there is no dedicated command to load any components. The libraries are called upon when needed.

Mixed Environments

If your goal is to create an array of graphic cards and make a GPU-driven render farm, it's easiest to keep your environment as homogeneous as possible. Mixing AMD and Nvidia GPUs leads to competing drivers sometimes to the point of a non-booting system. It's possible to use a mixed environment, but it make things far more complex.

OpenCL Apps

Not all applications use OpenCL, and not all applications would benefit from OpenCL if they did use it. Currently, the two most significant OpenCL applications are Blender, LuxRender, and GIMP (with Krita up-and-coming), but this list is sure to grow.

Blender and LuxRender will utilise OpenCL when it is available, so no further configuration is necessary.

To use OpenCL in GIMP, launch GIMP with this command:

GEGL_USE_OPENCL=yes gimp&

The actual impact of OpenCL will depend largely on what kind of tasks you are performing, and what kind of system you have.

See Also
Render Farming

R S Q