Skip to content

Building and Installing

James Price edited this page Feb 25, 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

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 install

Post-Install

Ensure that the lib directory in the Clang/SPIR generator build is covered by your dynamic library search path, adding it to [DY]LD_LIBRARY_PATH if necessary.

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.

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.

Clone this wiki locally