-
Notifications
You must be signed in to change notification settings - Fork 62
Building and Installing
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
.
If you are building directly from the GitHub repository, you need to run autoreconf -i
to generate the necessary build files. This is not required if you are using a released source package.
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=PATH
option. For example:
./configure --prefix=$PWD/build/ --with-spir=PATH/TO/CLANG/SPIR/BUILD
This path should be the directory in which the Clang/SPIR generator is installed (e.g. the path specified to --prefix
or CMAKE_INSTALL_PATH
when you configured the generator).
Next, build and install with make:
make
make install
make check
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-rt-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.
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 installation, (for example C:\Program Files\LLVM
). After configuring and generating with CMake, open the Oclgrind.sln
solution in Visual Studio and build the ALL_BUILD
target. Build the INSTALL
target to install Oclgrind (this may require Administrator privileges).
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-rt-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
CMake will generate a RUN_TESTS
project in Visual Studio which can be used to verify that Oclgrind is working correctly. It is recommended to run this after installing Oclgrind so that the precompiled headers can be used during the tests.
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 an issue on the GitHub Issues page: https://github.com/jrprice/Oclgrind/issues