Skip to content
Nico edited this page Jul 24, 2018 · 7 revisions

Build dependencies and library (no client) using install.sh

The install.sh script can be used to build the dependencies and the hipSPARSE library. Common uses of install.sh are in the table below.

install.sh_command description
./install.sh -h Help information.
./install.sh -d Build dependencies and library in your local directory. The -d flag only needs to be used once. For subsequent invocations of install.sh it is not necessary to rebuild the dependencies.
./install.sh Build library in your local directory. It is assumed dependencies have been built.
./install.sh -i Build library, then build and install hipSPARSE package. You will be prompted for sudo access. It is expected that if you want to install for all users you use the -i flag. If you want to keep hipSPARSE in your local directory, you do not need the -i flag.
./install.sh --cuda Build library in your local directory using cuSPARSE backend. It is assumed dependencies have been built.
./install.sh -d --cuda Build dependencies and library in your local directory using cuSPARSE backend.

Build library and client using install.sh

The install.sh script can be used to build the hipSPARSE library and client. The client contains executables in the table below.

executable name description
hipsparse-test run Google Tests to test the library
example-coomv example C code calling hipsparseDcoomv function
example-csrmv example C code calling hipsparseDcsrmv function
example-ellmv example C code calling hipsparseDellmv function
example-hybmv example C code calling hipsparseDhybmv function
example-handle example C code creating and destroying a hipSPARSE handle

Note that the client requires additional dependencies not needed by the library. These include googletest. Below are common uses of install.sh to build the dependencies, library, and client

install.sh_command description
./install.sh -h Help information.
./install.sh -dc Build dependencies, library, and client in your local directory. The -d flag only needs to be used once. For subsequent invocations of install.sh it is not necessary to rebuild the dependencies.
./install.sh -c Build library and client in your local directory. It is assumed the dependencies have been built.
./install.sh -idc Build dependencies, build the library, build the client, then build and install the hipSPARSE package. You will be prompted for sudo access. It is expected that if you want to install for all users you use the -i flag. If you want to keep hipSPARSE in your local directory, you do not need the -i flag.
./install.sh -ic Build and install hipSPARSE package and build the client. You will be prompted for sudo access. It is expected that if you want to install for all users you use the -i flag. If you want to keep hipSPARSE in your local directory, you do not need the -i flag.

Note: Adding the --cuda flag will run the script using cuSPARSE backend.

Dependencies For Building Library

CMake 3.5 or later

The build infrastructure for hipSPARSE 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 X system, we recommend using ccmake; if you have access to X, we recommend using cmake-gui.

Install one-liners cmake:

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

rocSPARSE

hipSPARSE is based on rocSPARSE. Currently, while rocSPARSE is not available in the public ROCm repositories, you will have to install the package manually. The current alpha release package is available in hipSPARSE/deps directory. You can install it using

  • Ubuntu: sudo dpkg -i ./deps/rocsparse*.deb
  • Fedura: currently not supported

Configure and build steps

Example steps to build hipSPARSE:

mkdir -p [HIPSPARSE_BUILD_DIR]/release
cd [HIPSPARSE_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
cmake [HIPSPARSE_SOURCE]
make -j$(nproc)
sudo make install # sudo required if installing into system directory such as /opt/rocm

Additional dependencies only necessary for hipSPARSE clients

The unit tests and benchmarking applications in the client introduce the following dependencies:

  1. googletest

Unfortunately, googletest is not as easy to install. Many distros do not provide a googletest package with pre-compiled libraries. hipSPARSE provides a cmake script that builds the above dependencies 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 dependencies and install them to the cmake default /usr/local.

(optional, one time only)

mkdir -p [HIPSPARSE_BUILD_DIR]/release/deps
cd [HIPSPARSE_BUILD_DIR]/release/deps
ccmake -DBUILD_BOOST=OFF [HIPSPARSE_SOURCE]/deps
make -j$(nproc) install

Build Library + Tests + Benchmarks + Samples Using Individual Commands

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 (e.g. /usr/local ), the user should pass the CMAKE_PREFIX_PATH to cmake to help finding them.

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

Common build problems

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

    ROCSPARSEConfig.cmake

    rocsparse-config.cmake

    Solution: Install rocSPARSE

  • 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

Clone this wiki locally