2. Installation and Building for Linux#
2.1. Prerequisites#
hipSPARSELt requires a ROCm enabled platform, more information here.
2.2. Installing pre-built packages#
hipSPARSELt can be installed from AMD ROCm repository. For detailed instructions on how to set up ROCm on different platforms, see the AMD ROCm Platform Installation Guide for Linux.
hipSPARSELt can be installed on e.g. Ubuntu using
$ sudo apt-get update
$ sudo apt-get install hipsparselt
Once installed, hipSPARSELt can be used just like any other library with a C API. The header file will need to be included in the user code in order to make calls into hipSPARSELt, and the hipSPARSELt shared library will become link-time and run-time dependent for the user application.
2.3. Building hipSPARSELt from source#
Building from source is not necessary, as hipSPARSELt can be used after installing the pre-built packages as described above. If desired, the following instructions can be used to build hipSPARSELt from source. Furthermore, the following compile-time dependencies must be met
CMake 3.5 or later
googletest (optional, for clients)
2.3.1. Download hipSPARSELt#
The hipSPARSELt source code is available at the hipSPARSELt GitHub page. Download the develop branch using:
$ git clone -b develop https://github.com/ROCmSoftwarePlatform/hipSPARSELt.git
$ cd hipSPARSELt
Below are steps to build different packages of the library, including dependencies and clients. It is recommended to install hipSPARSELt using the install.sh script.
2.3.2. Using install.sh to build hipSPARSELt with dependencies#
The following table lists common uses of install.sh to build dependencies + library.
Command |
Description |
---|---|
./install.sh -h |
Print 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 are available. |
./install.sh -i |
Build library, then build and install hipSPARSELt package in /opt/rocm/hipsparselt. You will be prompted for sudo access. This will install for all users. |
2.3.3. Using install.sh to build hipSPARSELt with dependencies and clients#
The client contains example code and unit tests. Common uses of install.sh to build them are listed in the table below.
Command |
Description |
---|---|
./install.sh -h |
Print 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 dependencies are available. |
./install.sh -idc |
Build library, dependencies and client, then build and install hipSPARSELt package in /opt/rocm/hipsparselt. You will be prompted for sudo access. This will install for all users. |
./install.sh -ic |
Build library and client, then build and install hipSPARSELt package in opt/rocm/hipsparselt. You will be prompted for sudo access. This will install for all users. |
2.3.4. Using individual commands to build hipSPARSELt#
CMake 3.16.8 or later is required in order to build hipSPARSELt.
hipSPARSELt can be built using the following commands:
# Create and change to build directory
$ mkdir -p build/release ; cd build/release
# Default install path is /opt/rocm, use -DCMAKE_INSTALL_PREFIX=<path> to adjust it
$ cmake ../..
# Compile hipSPARSELt library
$ make -j$(nproc)
# Install hipSPARSELt to /opt/rocm
$ make install
GoogleTest is required in order to build hipSPARSELt clients.
hipSPARSELt with dependencies and clients can be built using the following commands:
# Install googletest
$ mkdir -p build/release/deps ; cd build/release/deps
$ cmake ../../../deps
$ make -j$(nproc) install
# Change to build directory
$ cd ..
# Default install path is /opt/rocm, use -DCMAKE_INSTALL_PREFIX=<path> to adjust it
$ cmake ../.. -DBUILD_CLIENTS_TESTS=ON -DBUILD_CLIENTS_SAMPLES=ON
# Compile hipSPARSELt library
$ make -j$(nproc)
# Install hipSPARSELt to /opt/rocm
$ make install
2.3.5. Simple Test#
You can test the installation by running one of the hipSPARSELt examples, after successfully compiling the library with clients.
# Navigate to clients binary directory
$ cd hipSPARSELt/build/release/clients/staging
# Execute hipSPARSELt example
$ ./example_spmm_strided_batched -m 32 -n 32 -k 32 --batch_count 1
2.4. Supported Targets#
Currently, hipSPARSELt is supported under the following operating systems
To compile and run hipSPARSELt, AMD ROCm Platform is required.