-
Notifications
You must be signed in to change notification settings - Fork 62
Building and Installing
This page provides information about building Oclgrind from source. Binary packages for various operating systems are released periodically on the GitHub Releases page.
To build this project, you will require the LLVM and Clang 3.6 development libraries and headers. With some modifications, it may also be possible to use other versions of LLVM. If building LLVM from source, it is recommended to enable optimizations to improve the performance of Oclgrind (configure with --enable-optimized
, or set CMAKE_BUILD_TYPE
to RelWithDebInfo
).
You will also need a compiler that supports C++11.
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 LLVM/Clang includes and libraries on your
search path, you should specify the location of the generator using the --with-llvm=PATH
option. For example:
./configure --prefix=$PWD/build/ --with-llvm=PATH/TO/CLANG/SPIR/BUILD
This path should be the directory in which LLVM is installed (e.g. the path specified to --prefix
or CMAKE_INSTALL_PATH
when LLVM was built).
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. You may also need to add the lib/
directory to your [DY]LD_LIBRARY_PATH
environment variable.
If you wish to use Oclgrind via the OpenCL ICD (optional), then you create an ICD loading point by copying the oclgrind.icd
file from the build directory to /etc/OpenCL/vendors/
.
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 may be prompted to supply a value for the LLVM_DIR
parameter. This should be set to the directory containing your LLVM installations's LLVMConfig.cmake
file, (for example C:\Program Files\LLVM\share\llvm\cmake\
). 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