Build Instructions OpenCL - 3dct/open_iA GitHub Wiki

Up to Windows Build / Linux Build.

OpenCL is required for the GPU-acceleration of some ITK filters available in open_iA, and the acceleration of some tools (e.g. DreamCaster) in open_iA.

OpenCL option 1: Vendor SDK

If you only want to build for the machine you are currently running (or similar machines with the same graphics card vendor), you can choose the OpenCL/GPU development kit from the respective hardware vendor:

Install the respective SDK. When configuring open_iA later (see open_iA section below), you will need to point CMake to the OpenCL header files (typically an include subfolder of the SDK installation folder) as well as the "OpenCL.lib" library file inside the SDK installation folder.

OpenCL option 2: ICD Loader

Linux users have it easy, most distributions provide pre-built packages (recommended). Install via $ sudo apt install ocl-icd-opencl-dev opencl-headers opencl-clhpp-headers.

Alternatively, or on Windows build the ICD loader yourself; this is slightly more complicated, but in the end you get an open_iA binary which can use existing OpenCL capabilities on any hardware. You will have to build the OpenCL ICD loader from the Khronos Group, which in short will be explained here:

  • Clone or download the ICD Loader (https://github.com/KhronosGroup/OpenCL-ICD-Loader)
  • Clone or download the C OpenCL headers (https://github.com/KhronosGroup/OpenCL-Headers)
    • copy the "CL" directory from this download into "inc" subdirectory of the folder where you cloned/extracted the ICD Loader
  • Clone or download the C++ OpenCL headers (https://github.com/KhronosGroup/OpenCL-CLHPP)
    • These headers need to be built.
    • As prerequisite, install python and make sure it is on the PATH (i.e. when starting a command prompt and entering "python --version" followd by , you should get version output about python)
    • Start CMake, with the downloaded CLHPP folder as source, and some empty folder as binary folder
    • For our purposes, you can uncheck "BUILD_DOCS", "BUILD_EXAMPLES" and "BUILD_TESTS"
    • Finish configuration and generation in CMake
    • Open generated project in build tool (e.g. Visual Studio)
    • Build the solution
    • Make sure that the include/CL subfolder of the selected binary folder contains cl.hpp as well as cl2.hpp (if it doesn't contain one of them, check the output of the build process for errors)
    • Copy the content of the include/CL subfolder of the selected binary folder into the CL folder created when copying the C OpenCL headers (i.e. in the inc/CL subfolder of the ICD-Loader source folder)
  • To build the ICD Loader library:
    • Start CMake, with the downloaded ICD Loader folder as source, and some empty folder as binary folder
    • When asked for the generator, make sure to select "x64" in the "Platform" combo box.
    • For our purposes, you can uncheck "BUILD_TESTS", but make sure "BUILD_SHARED_LIBS" is checked.
    • Finish configuration and generation in CMake
    • Open generated project in build tool (e.g. Visual Studio)
    • Build the solution.

You can now use the "inc" folder in the ICD-Loader source directory as OpenCL_INCLUDE_DIRS as well as e.g. the Release/OpenCL.lib as OPENCL_LIBRARIES when building ITK and open_iA. The resulting build should be independent of which vendor's OpenCL compute capabilities are available.

Navigation:

⚠️ **GitHub.com Fallback** ⚠️