Under Windows and Mac the Intel GPU drivers include OpenCL support; however, on Linux OpenCL on Intel GPUs is implemented through an open source project called Beignet (pronnounced like "ben-yay", a type of French pastry akin to a what we would call a "fritter" in English). Below I have written a step-by-step guide on how you can get Beignet running on an Ubuntu 14.10 system which has an Intel 3rd, 4th, or 5th generation Intel processor. Instructions for other variants of Linux will be similar, except for the commands to install the prerequisite packages.

There are several little caveats which need to be discussed up front. Foremost, the Beignet project supports the following hardware:

3rd Generation Intel Core Processors

Intel “Bay Trail” platforms with Intel HD Graphics

4th Generation Intel Core Processors (requires a kernel patch be applied for shared memory!)

5th Generation Intel Core Processors "Broadwell".

There are also a few noteworthy issues of which you should be aware:

If your computer is running a Linux kernel in the 3.15 or 3.16 branch, you will need to disable some register whitelist functionality every time you reboot your system. This can be accomplished by running echo 0 > /sys/module/i915/parameters/enable_cmd_parser as root.

as root. 4th Generation Intel Processors (i.e. i3/5/7-4xxx) require a kernel patch for shared/local memory to function.

There is no double precision support

OpenGL-OpenCL interop via cl_khr_gl_sharing is not supported

There are additional release notes that can be found on the Beignet project page.

Installing prerequisites

sudo apt-get install build-essential g++ cmake sudo apt-get install clang libclang-3.5-dev libclang-dev libclang1 sudo apt-get install ocl-icd-opencl-dev ocl-icd-libopencl1 1 2 3 4 sudo apt - get install build - essential g ++ cmake sudo apt - get install clang libclang - 3.5 - dev libclang - dev libclang1 sudo apt - get install ocl - icd - opencl - dev ocl - icd - libopencl1

libclang-3.4-dev

update-alternatives

llvm-link

llvm-as

sudo update-alternatives --install /usr/bin/llvm-link llvm-link /usr/bin/llvm-link-3.4 34 sudo update-alternatives --install /usr/bin/llvm-as llvm-as /usr/bin/llvm-as-3.4 34 1 2 3 4 sudo update - alternatives -- install / usr / bin / llvm - link llvm - link / usr / bin / llvm - link - 3.4 34 sudo update - alternatives -- install / usr / bin / llvm - as llvm - as / usr / bin / llvm - as - 3.4 34

sudo apt-get install opencl-headers ocl-icd-dev ocl-icd-libopencl1 1 2 3 sudo apt - get install opencl - headers ocl - icd - dev ocl - icd - libopencl1

clinfo

sudo apt-get install clinfo 1 2 3 sudo apt - get install clinfo

Check out and compile Beignet

git clone git://anongit.freedesktop.org/beignet cd beignet git checkout Release_v1.0.0 mkdir build cd build cmake .. 1 2 3 4 5 6 7 8 git clone git : //anongit.freedesktop.org/beignet cd beignet git checkout Release_v1 . 0.0 mkdir build cd build cmake . .

git branch - a

Note, if you are on a Ubuntu 14.04 system, you should installinstead, then runto pointandto the correct version. The latter can be accomplished using the following commands:If you want to use the standard OpenCL ICD loader, you will also need to install these packages:I would also recomment you install theprogram so that you can verify that your installation is successful:NOTE: There may be newer releases of Beinget. To find releases typeon the console and pick the highest release version number.

During the CMake stage, ensure that the OCL ICD header file is installed, otherwise the library will not create an installable client driver. If everything went fine, go ahead and compile the source using

make 1 2 3 make

(Note, you can do make -jN with N > 1 to do a parallel build.)

Next we verify that Beignet is functioning correctly on your hardware by running unit tests. These can be found in the utest folder. The unit tests require some enviornmental variables be set prior to invocation:

cd utests source setenv.sh ./utest_run 1 2 3 4 5 cd utests source setenv . sh . / utest _ run

If a significant fraction of the unit tests fail and you have a 3.15 or 3.16 kernel, you need to disable register whitelisting using a command similar to the following:

sudo su echo 0 > /sys/module/i915/parameters/enable_cmd_parser exit 1 2 3 4 5 sudo su echo 0 & gt ; / sys / module / i915 / parameters / enable_cmd_parser exit

and try re-running the tests. Please note that this change is not permanent and you will need to re-run it if you reboot your system. Alternatively, you could add this command to a startup script. The Beignet release notes mention there is a kernel patch to fix this issue which you could backport if you so desired.

If most of the tests pass, but those that involve local memory (~20-30 of the tests) fail, you will need to apply the kernel patch listed below.

If all was well, install Beignet to your system:

sudo make install 1 2 3 sudo make install

You can see a list of installed software in the install_manifest.txt file in the build directory.

Verify Beignet is installed

In a terminal run the clinfo program. You should see something like this:

$ clinfo ... Platform Name: Intel Gen OCL Driver Number of devices: 1 Device Type: CL_DEVICE_TYPE_GPU ... Name: Intel(R) HD Graphics Haswell GT2 Desktop Vendor: Intel Device OpenCL C version: OpenCL C 1.2 beignet 0.9.1 Driver version: 0.9.1 Profile: FULL_PROFILE Version: OpenCL 1.2 beignet 0.9.1 Extensions: 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_icd 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 $ clinfo . . . Platform Name : Intel Gen OCL Driver Number of devices : 1 Device Type : CL_DEVICE_TYPE _ GPU . . . Name : Intel ( R ) HD Graphics Haswell GT2 Desktop Vendor : Intel Device OpenCL C version : OpenCL C 1.2 beignet 0.9.1 Driver version : 0.9.1 Profile : FULL_PROFILE Version : OpenCL 1.2 beignet 0.9.1 Extensions : 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 _ icd

Take note that the Intel OpenCL driver is loaded for a GPU device using beignet . This indicates the Installable Client Driver (ICD) is correctly installed. Also note the extensions listed.

Applying the kernel patch to enable OpenCL shared local memory.

If you are using Beignet on a 4th generation Intel processor, you will need to apply a kernel patch to enable shared/local memory. This is a fairly lengthy process that will require at least 70 GB of hard disk space and perhaps an hour of compilation time if the build is executed in parallel.

In the next few paragraphs I'll walk you through how you can apply the kernel patch. I have based my instructions on the kernel compilation instructions for Ubuntu. Instructions for other variants of Linux will be significantly different.

Install prerequisites:

sudo apt-get build-dep linux-image-`uname -r` 1 2 3 sudo apt - get build - dep linux - image - ` uname - r `

Make a working directory for the kernel somewhere and download the source

mkdir kernel cd kernel apt-get source linux-image-`uname -r` 1 2 3 4 5 mkdir kernel cd kernel apt - get source linux - image - ` uname - r `

Next we see if we can automatically apply the patch. First download the patch:

wget https://01.org/sites/default/files/disable-batchbuffer-security.patch 1 2 3 wget https : //01.org/sites/default/files/disable-batchbuffer-security.patch

Now cd into the kernel directory:

cd linux-3.16.0 1 2 3 cd linux - 3.16.0

Check some details about the patch

git apply --stat ../disable-batchbuffer-security.patch 1 2 3 git apply -- stat . . / disable - batchbuffer - security . patch

Try automatically applying the patch:

git apply --check ../disable-batchbuffer-security.patch 1 2 3 git apply -- check . . / disable - batchbuffer - security . patch

If it automatically applies with no errors, just apply it:

git apply ../disable-batchbuffer-security.patch 1 2 3 git apply . . / disable - batchbuffer - security . patch

If it did not work (as was the case on my system), the change is fairly simple. Open the drivers/gpu/drm/i915/i915_gem_execbuffer.c file in an editor:

gedit drivers/gpu/drm/i915/i915_gem_execbuffer.c 1 2 3 gedit drivers / gpu / drm / i915 / i915_gem_execbuffer . c

In the i915_gem_do_execbuffer function, find the following code:

flags = 0; if (args->flags & I915_EXEC_SECURE) { if (!file->is_master || !capable(CAP_SYS_ADMIN)) return -EPERM; 1 2 3 4 5 6 flags = 0 ; if ( args - & gt ; flags & amp ; I915_EXEC_SECURE ) { if ( ! file - & gt ; is_master || ! capable ( CAP_SYS_ADMIN ) ) return - EPERM ;

And add the line flags |= I915_DISPATCH_SECURE; as follows:

flags = 0; flags |= I915_DISPATCH_SECURE; if (args->flags & I915_EXEC_SECURE) { if (!file->is_master || !capable(CAP_SYS_ADMIN)) return -EPERM; 1 2 3 4 5 6 7 flags = 0 ; flags |= I915_DISPATCH_SECURE ; if ( args - & gt ; flags & amp ; I915_EXEC_SECURE ) { if ( ! file - & gt ; is_master || ! capable ( CAP_SYS_ADMIN ) ) return - EPERM ;

This was inserted on line 998 for me. Save the file. Now we need to compile and install the modified kernel.

Now we build the new kernel. Run the following commands from within the kernel source directory:

fakeroot debian/rules clean DEB_BUILD_OPTIONS=parallel=8 fakeroot debian/rules binary-headers binary-generic 1 2 3 4 fakeroot debian / rules clean DEB_BUILD_OPTIONS = parallel = 8 fakeroot debian / rules binary - headers binary - generic

This will build some Debian packages and place them in the directory above the kernel source root.

After the kernel has compiled, install it:

cd ../ (or go back into the kernel directory) sudo dpkg -i linux-headers-3.16.0-29-generic_3.16.0-29.54_amd64.deb sudo dpkg -i linux-image-3.16.0-29-generic_3.16.0-29.54_amd64.deb 1 2 3 4 5 cd . . / ( or go back into the kernel directory ) sudo dpkg - i linux - headers - 3.16.0 - 29 - generic_3 . 16.0 - 29.54_amd64.deb sudo dpkg - i linux - image - 3.16.0 - 29 - generic_3 . 16.0 - 29.54_amd64.deb

(you might have to change the numeric kernel version to match what you compiled) Now add the kernel to the boot options:

sudo update-grub sudo reboot 1 2 3 4 sudo update - grub sudo reboot

Now go back and re-run the Beignet unit test framework from above. With any luck everything will work fine.