Skip to content

Latest commit

 

History

History
294 lines (204 loc) · 12 KB

compilation.md

File metadata and controls

294 lines (204 loc) · 12 KB

Compilation

The latest Intel Open Image Denoise sources are always available at the Intel Open Image Denoise GitHub repository. The default master branch should always point to the latest tested bugfix release.

Prerequisites

You can clone the latest Intel Open Image Denoise sources using Git with the Git Large File Storage (LFS) extension installed:

git clone --recursive https://github.com/OpenImageDenoise/oidn.git

Please note that installing the Git LFS extension is required to correctly clone the repository. Cloning without Git LFS will seemingly succeed but actually some of the files will be invalid and thus compilation will fail.

Intel Open Image Denoise currently supports 64-bit Linux, Windows, and macOS operating systems. Before you can build Intel Open Image Denoise you need the following basic prerequisites:

  • CMake 3.15 or newer

  • A C++11 compiler (we recommend using a Clang-based compiler but also support GCC and Microsoft Visual Studio 2015 and newer)

  • Python 3

To build support for different types of CPUs and GPUs, the following additional prerequisites are needed:

CPU device: {-}

  • Intel® SPMD Program Compiler (ISPC) 1.21.0 or newer. Please obtain a release of ISPC from the ISPC downloads page. The build system looks for ISPC in the PATH and in the directory right "next to" the checked-out Intel Open Image Denoise sources. For example, if Intel Open Image Denoise is in ~/Projects/oidn, ISPC will also be searched in ~/Projects/ispc-v1.21.0-linux. Alternatively set the CMake variable ISPC_EXECUTABLE to the location of the ISPC compiler.

  • Intel® Threading Building Blocks (TBB) 2017 or newer

SYCL device for Intel GPUs: {-}

CUDA device for NVIDIA GPUs: {-}

HIP device for AMD GPUs: {-}

Metal device for Apple GPUs: {-}

Depending on your operating system, you can install some required dependencies (e.g., TBB) using yum or apt-get on Linux, Homebrew or MacPorts on macOS, and vcpkg on Windows. For the other dependencies please download the necessary packages or installers and follow the included instructions.

Compiling on Linux/macOS

If you are building with SYCL support on Linux, make sure that the DPC++ compiler is properly set up. The open source oneAPI DPC++ Compiler can be downloaded and simply extracted. However, before using the compiler, the environment must be set up as well with the following command:

source ./dpcpp_compiler/startup.sh

The startup.sh script will put clang and clang++ from the oneAPI DPC++ Compiler into your PATH.

Alternatively, if you have installed Intel® oneAPI DPC++/C++ Compiler instead, you can set up the compiler by sourcing the vars.sh script in the env directory of the compiler install directory, for example,

source /opt/intel/oneAPI/compiler/latest/env/vars.sh

This script will put the icx and icpx compiler executables from the Intel(R) oneAPI DPC++/C++ Compiler in your PATH.

  • Create a build directory, and go into it using a command prompt

    mkdir oidn/build
    cd oidn/build
    

    (We do recommend having separate build directories for different configurations such as release, debug, etc.).

  • CMake will use the default compiler, which on most Linux machines is gcc, but it can be switched to clang by executing the following:

    cmake -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ..
    

    If you are building with SYCL support, you must set the DPC++ compiler (clang/clang++ or icx/icpx) as the C/C++ compiler here. Note that the compiler variables cannot be changed after the first cmake or ccmake run.

  • Open the CMake configuration dialog

    ccmake ..
    
  • Make sure to properly set the build mode and enable the components and options you need. By default only CPU support is built, so SYCL and other device support must be enabled manually (e.g. with the OIDN_DEVICE_SYCL option). Then type 'c'onfigure and 'g'enerate. When back on the command prompt, build the library using

    ninja
    

Compiling on Windows

If you are building with SYCL support, make sure that the DPC++ compiler is properly set up. The open source oneAPI DPC++ Compiler can be downloaded and simply extracted. However, before using the compiler, the environment must be set up. To achieve this, open the "x64 Native Tools Command Prompt for VS" that ships with Visual Studio and execute the following commands:

set "DPCPP_DIR=path_to_dpcpp_compiler"
set "PATH=%DPCPP_DIR%\bin;%PATH%"
set "PATH=%DPCPP_DIR%\lib;%PATH%"
set "CPATH=%DPCPP_DIR%\include;%CPATH%"
set "INCLUDE=%DPCPP_DIR%\include;%INCLUDE%"
set "LIB=%DPCPP_DIR%\lib;%LIB%"

The path_to_dpcpp_compiler should point to the unpacked oneAPI DPC++ Compiler.

Alternatively, if you have installed Intel® oneAPI DPC++/C++ Compiler instead, you can either open a regular "Command Prompt" and execute the vars.bat script in the env directory of the compiler install directory, for example

C:\Program Files (x86)\Intel\oneAPI\compiler\latest\env\vars.bat

or simply open the installed "Intel oneAPI command prompt for Intel 64 for Visual Studio". Either way, the icx compiler executable from the Intel® oneAPI DPC++/C++ Compiler will be added to your PATH.

On Windows we highly recommend to use Ninja as the CMake generator because not all devices can be built using the Visual Studio generator (e.g. SYCL).

  • Create a build directory, and go into it using a Visual Studio command prompt

    mkdir oidn/build
    cd oidn/build
    

    (We do recommend having separate build directories for different configurations such as release, debug, etc.).

  • CMake will use the default compiler, which on most Windows machines is MSVC, but it can be switched to clang by executing the following:

    cmake -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ..
    

    If you are building with SYCL support, you must set the DPC++ compiler (clang/clang++ or icx) as the C/C++ compiler here. Note that the compiler variables cannot be changed after the first cmake or cmake-gui run.

  • Open the CMake GUI (cmake-gui.exe)

    cmake-gui ..
    
  • Make sure to properly set the build mode and enable the components and options you need. By default only CPU support is built, so SYCL and other device support must be enabled manually (e.g. OIDN_DEVICE_SYCL option). Then click on Configure and Generate. When back on the command prompt, build the library using

    ninja
    

CMake Configuration

The following list describes the options that can be configured in CMake:

  • CMAKE_BUILD_TYPE: Can be used to switch between Debug mode (Debug), Release mode (Release) (default), and Release mode with enabled assertions and debug symbols (RelWithDebInfo).

  • OIDN_STATIC_LIB: Build Open Image Denoise as a static (if only CPU support is enabled) or a hybrid static/shared (if GPU support is enabled as well) library.

  • OIDN_API_NAMESPACE: Specifies a namespace to put all Intel Open Image Denoise API symbols inside. This is also added as an outer namespace for the C++ wrapper API. By default no namespace is used and plain C symbols are exported.

  • OIDN_DEVICE_CPU: Enable CPU device support (ON by default).

  • OIDN_DEVICE_SYCL: Enable SYCL device support for Intel GPUs (OFF by default).

  • OIDN_DEVICE_SYCL_AOT: Enable ahead-of-time (AOT) compilation for SYCL kernels (ON by default). Turning this off removes dependency on OCLOC at build time and decreases binary size but significantly increases initialization time at runtime, so it is recommended only for development.

  • OIDN_DEVICE_CUDA: Enable CUDA device support for NVIDIA GPUs (OFF by default).

  • OIDN_DEVICE_CUDA_API: Use the CUDA driver API (Driver, default), the static CUDA runtime library (RuntimeStatic), or the shared CUDA runtime library (RuntimeShared).

  • OIDN_DEVICE_HIP: Enable HIP device support for AMD GPUs (OFF by default).

  • OIDN_DEVICE_METAL: Enable Metal device support for Apple GPUs (OFF by default).

  • OIDN_FILTER_RT: Include the trained weights of the RT filter in the build (ON by default). Turning this OFF significantly decreases the size of the library binary, while the filter remains functional if the weights are set by the user at runtime.

  • OIDN_FILTER_RTLIGHTMAP: Include the trained weights of the RTLightmap filter in the build (ON by default).

  • OIDN_APPS: Enable building example and test applications (ON by default).

  • OIDN_APPS_OPENIMAGEIO: Enable OpenImageIO support in the example and test applications to be able to load/save OpenEXR, PNG, and other image file formats (OFF by default).

  • OIDN_INSTALL_DEPENDENCIES: Enable installing the dependencies (e.g. TBB, SYCL runtime) as well.

  • TBB_ROOT: The path to the TBB installation (autodetected by default).

  • ROCM_PATH: The path to the ROCm installation (autodetected by default).

  • OPENIMAGEIO_ROOT: The path to the OpenImageIO installation (autodetected by default).