Skip to content

Building and Installing

James Price edited this page Mar 9, 2014 · 24 revisions

Clang/SPIR Generator

Oclgrind requires that a SPIR-capable version of Clang is available on the system. The Khronos working group has created a patched version of Clang 3.2 that can generate SPIR, and this is the recommended version to use with Oclgrind (some SPIR functionality is now available in the LLVM trunk, but this has not yet been extensively tested with Oclgrind). Follow the instructions in the README.md file to build the Clang/SPIR generator. For best performance, it is recommended to build Clang for release mode, using CMAKE_BUILD_TYPE=RelWithDebInfo.

Building Oclgrind on Linux or OS X

If you are building Oclgrind directly from the Git repository, run autoreconf -i to generate the necessary autotools files.

Run ./configure to generate the Makefile, optionally using --prefix=PATH to specify the target installation directory. If you don't have the Clang/SPIR generator includes and libraries on your search path, you should specify the location of the generator using the --with-spir=PATHoption. For example:

./configure --prefix=$PWD/build/ --with-spir=PATH/TO/CLANG/SPIR/BUILD

Next, build and install with make: make make install

If you have installed Oclgrind to a non-default location, you may wish to add the bin/ directory to your PATH environment variable in order to make use of the oclgrind command.

If you wish to use Oclgrind via the OpenCL ICD (optional), then you should also create an ICD loading point. To do this, create the file /etc/OpenCL/vendors/oclgrind.icd which should contain liboclgrind-icd.so (or .dylib on OS X), or the full path to this library if it isn't covered by your dynamic library search path.

Building Oclgrind on Windows

A CMake build system is provided for building Oclgrind on Windows. At present, this only works with Visual Studio 2013 (or newer), and Windows 7.

When configuring the CMake build, you will be prompted to supply a value for the SPIR_ROOT parameter. This should be set to the root directory of the Clang/SPIR generator, (for example C:\Program Files\LLVM).

If you wish to use Oclgrind via the OpenCL ICD (optional), then you should also create an ICD loading point. To do this, you should add a REG_DWORD value to the Windows Registry under one or both of the registry keys below, with the name set to the absolute path of the oclgrind-icd.dll library and the value set to 0.

Key for 32-bit machines or 64-bit apps on a 64-bit machine: HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenCL\Vendors

Key for 32-bit apps on a 64-bit machine: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Khronos\OpenCL\Vendors

Additional Notes

If you wish to use the OpenCL ICD and it is not already present on your system, you can download and build the sources from here.

To build the OpenCL ICD on OS X, modify the CMakeLists.txt file such that the first comparison of ${CMAKE_SYSTEM_NAME} with the string "Linux" instead compares to the string "Darwin". You can link OpenCL applications against the ICD by specifying -lOpenCL in your linker flags, instead of -framework OpenCL. Apple's OpenCL implementation does not yet support the OpenCL ICD, and so applications linked in this way will not be able to use the Apple OpenCL platform. There is a project here which allows the Apple OpenCL platform to be used via the ICD.

If you encounter any problems whilst building Oclgrind, please raise issue on the GitHub Issues page: https://github.com/jrprice/Oclgrind/issues

Clone this wiki locally