I just recently set about getting OpenCL working on my linux-based desktop. This was not as straightforward as I might have liked, mainly due to the lack of any centralised documentation. I hereby attempt to address that.
If you hadn't heard of OpenCL then you probably wouldn't be here, so I'll make this brief. OpenCL defines both a C-like programming language and standard library, and an API for getting programs written in the OpenCL language to execute on a processor (typically a GPU, but potentially also a standard CPU or something else such as a DSP). It's mainly targeted at allowing large numbers of parallel executions performing the same task (which is what GPUs tend to be good at).
The official standard is maintained by the Khronos group. They define it as "The open standard for parallel programming of heterogeneous system", which as far as I'm concerned is a fancy way of saying that it allows controlling one processing unit from another.
Some terminology:
Because OpenCL defines an API you need a library which implements that API in order to use it. On linux the OpenCL library is called libOpenCL.so and it lives in /usr/lib (as might be expected). Because you potentially have multiple OpenCL devices on your system that might support OpenCL, you also potentially have multiple implementations of this library. Fortunately, however, the OpenCL standard (or at least, an extension to it) specifies the concept of an Installable Client Driver or ICD. An OpenCL "driver" implementation can provide an ICD, and then the main OpenCL library (the "ICD loader") can load the ICD to provide access to the device(s) that it handles.
The standardised way for the OpenCL library to find available ICDs is by lookin in the /etc/OpenCL/vendors directory for '.icd' files, which are text files containing the full filename (but not path) of a dynamic library which implements the ICD.
OpenCL headers
The OpenCL header files can be obtained from the Khronos registry. They are also bundled with the Mesa library (though need to be installed manually).ICD loaders
It seems that OpenCL implementation providers tend to provide both a loader and an ICD. There are, however, seemingly two loader-only implementations:
Radeon GPUs
The primary open-source implementation of OpenCL for Radeon GPUs is Mesa (which is also the extant open-source OpenGL implementation) which seemingly incorporates part or all of Clover, itself an OpenCL implementation for running kernels on the host processor). The build documentation for Mesa is in general pretty woeful. Documentation on freedesktop.org seems like it's out of date. OpenCL support is only available for certain Radeon devices (using the gallium driver). If you want to build this support, you must:
For Radeon devices there is also the option of using AMD's closed-source OpenCL implementation (64-bit only; works only in conjunction with their "Catalyst" display driver). They provide both an ICD and loader (in the one package). I haven't tried this; I prefer using an open-source solution.
NVidia GPUs
I don't own one of these, so there's little I can say. NVidia provide a closed-source OpenCL implementation (loader and ICD, I think).
Intel GPUs
The Beignet project provides an open-source OpenCL implementation for Intel GPUs. It can apparently be built as either an ICD or a standalone library. It uses LLVM (but has its own implementation of the OpenCL runtime). I have not tried it yet.
CPUs
There are also some open source alternatives:
I will add other implementations to the list as I find them.