Skip to content

Build on ROCM

tingxingdong edited this page Apr 20, 2018 · 1 revision

Dependencies For Building Library

CMake 3.5 or later

The build infrastructure for rocFFT is based on Cmake v3.5. This is the version of cmake available on ROCm supported platforms. If you are on a headless machine without the x-windows system, we recommend using ccmake; if you have access to X-windows, we recommend using cmake-gui.

Install one-liners cmake:

  • Ubuntu: sudo apt install cmake-qt-gui
  • Fedora: sudo dnf install cmake-gui

Build Library Using Script (Ubuntu only)

The root of this repository has a helper bash script install.sh to build and install rocFFT on Ubuntu with a single command. It does not take a lot of options and hard-codes configuration that can be specified through invoking cmake directly, but it's a great way to get started quickly and can serve as an example of how to build/install. A few commands in the script need sudo access, so it may prompt you for a password.

  • ./install.sh -h -- shows help
  • ./install.sh -id -- build library, build dependencies and install (-d flag only needs to be passed once on a system)
  • ./install -c --cuda -- build library and clients for cuda backend into a local directory

Build Library Using Individual Commands

The rocFFT library contains both host and device code, so the HCC compiler must be specified during cmake configuration to properly initialize build tools.

Configure and build steps

mkdir -p [ROCFFT_BUILD_DIR]/release
cd [ROCFFT_BUILD_DIR]/release
# Default install location is in /opt/rocm, define -DCMAKE_INSTALL_PREFIX=<path> to specify other
# Default build config is 'Release', define -DCMAKE_BUILD_TYPE=<config> to specify other
CXX=/opt/rocm/bin/hcc ccmake [ROCFFT_SOURCE]
make -j$(nproc)
sudo make install # sudo required if installing into system directory such as /opt/rocm

Build Library + Tests + Benchmarks + Samples Using Individual Commands

The repository contains source for clients that serve as samples, tests and benchmarks. Clients source can be found in the clients subdir.

Dependencies (only necessary for rocFFT clients)

The rocFFT samples have no external dependencies, but our unit test and benchmarking applications do. These clients introduce the following dependencies:

  1. boost
  2. FFTW3
  3. googletest

Linux distros typically have an easy installation mechanism for boost & fftw through the native package manager.

  • Ubuntu: sudo apt install libboost-program-options-dev libfftw3-dev
  • Fedora: sudo dnf install boost-program-options

Unfortunately, googletest is not as easy to install. Many distros do not provide a googletest package with pre-compiled libraries. rocFFT provide a cmake script that builds googletest or boost from source. This is an optional step; users can provide their own builds of these dependencies and help cmake find them by setting the CMAKE_PREFIX_PATH definition. The following is a sequence of steps to build googletest and and install it through the cmake scripts provided in rocFFT, into default /usr/local.

Googletest build

mkdir -p [ROCFFT_BUILD_DIR]/release/deps
cd [ROCFFT_BUILD_DIR]/release/deps
ccmake -DBUILD_BOOST=OFF [ROCFFT_SOURCE]/deps   # turn boost build off, compiling fftw from source is not supported yet
make -j$(nproc) install

Manual FFTW build

The test binaries from rocFFT use FFTW as the gold version to compare against. FFTW is an open-source project and for the Linux platform it is expected for the user to download the source from the FFTW download site and compile the source.

Read the FFT install doc carefully, e.g., during configuration stage you may enable float like this

./configure --enable-float
sudo make
sudo make install

since you by default it builds with double precision. You may need to build twice (one with and one without) to get both single and double library.

If you use Cmake-gui, hit the "Add Entry" button and add a PATH named FFTW_ROOT and set the value. For example, my FFTW_ROOT = /usr/local/. Make sure libfftw3.a and lifftw3f.a are both in FFTW_ROOT/lib

If you use ccmake (command line mode of cmake-gui), make sure it build with -DFFTW_ROOT=/usr/local/

Once dependencies are available on the system, it is possible to configure the clients to build. This requires a few extra cmake flags to the library cmake configure script. If the dependencies are not installed into system defaults (like /usr/local ), you should pass the CMAKE_PREFIX_PATH to cmake to help find them.

  • -DCMAKE_PREFIX_PATH="<semicolon separated paths>"
# Default install location is in /opt/rocm, use -DCMAKE_INSTALL_PREFIX=<path> to specify other
CXX=/opt/rocm/bin/hcc ccmake -DBUILD_CLIENTS_TESTS=ON -DBUILD_CLIENTS_BENCHMARKS=ON [ROCFFT_SOURCE]
make -j$(nproc)
sudo make install   # sudo required if installing into system directory such as /opt/rocm

CUDA builds

rocFFT is written with HIP kernels, so it can build and run on CUDA platforms.

Common build problems

  • Issue: HIP (/opt/rocm/hip) was built using hcc 1.0.xxx-xxx-xxx-xxx, but you are using /opt/rocm/hcc/hcc with version 1.0.yyy-yyy-yyy-yyy from hipcc. (version does not match) . Please rebuild HIP including cmake or update HCC_HOME variable.

    Solution: Download HIP from github and use hcc to build from source and then use the build HIP instead of /opt/rocm/hip one or singly overwrite the new build HIP to this location.

  • Issue: For Carrizo - HCC RUNTIME ERROR: Fail to find compatible kernel

    Solution: Add the following to the cmake command when configuring: -DCMAKE_CXX_FLAGS="--amdgpu-target=gfx801"

  • Issue: For MI25 (Vega10 Server) - HCC RUNTIME ERROR: Fail to find compatible kernel

    Solution: export HCC_AMDGPU_TARGET=gfx900

  • Issue: Could not find a package configuration file provided by "ROCM" with any of the following names:

    ROCMConfig.cmake

    rocm-config.cmake

    Solution: Install ROCm cmake modules

  • Issue: CMake Error at CMakeLists.txt:36 (find_package): Could not find a package configuration file provided by "rocfft" with any of the following names:

    rocfftConfig.cmake rocfft-config.cmake

Solution:: you used "./install.sh -dc", use "./install -d first to build *.so" first to see the earlier error