User Manual

Introduction

hipSPARSE is a library that contains basic linear algebra subroutines for sparse matrices and vectors written in HIP for GPU devices. It is designed to be used from C and C++ code. The functionality of hipSPARSE is organized in the following categories:

The code is open and hosted here: https://github.com/ROCmSoftwarePlatform/hipSPARSE

hipSPARSE is a SPARSE marshalling library, with multiple supported backends. It sits between the application and a worker SPARSE library, marshalling inputs into the backend library and marshalling results back to the application. hipSPARSE exports an interface that does not require the client to change, regardless of the chosen backend. Currently, hipSPARSE supports rocSPARSE and cuSPARSE as backends. hipSPARSE focuses on convenience and portability. If performance outweighs these factors, then using rocSPARSE itself is highly recommended. rocSPARSE can also be found on GitHub.

Building and Installing

Prerequisites

hipSPARSE requires a ROCm enabled platform, more information here.

Installing pre-built packages

hipSPARSE 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.

hipSPARSE can be installed on e.g. Ubuntu using

$ sudo apt-get update
$ sudo apt-get install hipsparse

Once installed, hipSPARSE 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 hipSPARSE, and the hipSPARSE shared library will become link-time and run-time dependent for the user application.

Building hipSPARSE from source

Building from source is not necessary, as hipSPARSE can be used after installing the pre-built packages as described above. If desired, the following instructions can be used to build hipSPARSE from source. Furthermore, the following compile-time dependencies must be met

Download hipSPARSE

The hipSPARSE source code is available at the hipSPARSE GitHub page. Download the master branch using:

$ git clone -b master https://github.com/ROCmSoftwarePlatform/hipSPARSE.git
$ cd hipSPARSE

Below are steps to build different packages of the library, including dependencies and clients. It is recommended to install hipSPARSE using the install.sh script.

Using install.sh to build hipSPARSE 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 hipSPARSE package in /opt/rocm/hipsparse. You will be prompted for sudo access. This will install for all users.

Using install.sh to build hipSPARSE 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 hipSPARSE package in /opt/rocm/hipsparse. You will be prompted for sudo access. This will install for all users.

./install.sh -ic

Build library and client, then build and install hipSPARSE package in opt/rocm/hipsparse. You will be prompted for sudo access. This will install for all users.

Using individual commands to build hipSPARSE

CMake 3.5 or later is required in order to build hipSPARSE.

hipSPARSE 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 hipSPARSE library
$ make -j$(nproc)

# Install hipSPARSE to /opt/rocm
$ make install

GoogleTest is required in order to build hipSPARSE clients.

hipSPARSE 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 hipSPARSE library
$ make -j$(nproc)

# Install hipSPARSE to /opt/rocm
$ make install

Simple Test

You can test the installation by running one of the hipSPARSE examples, after successfully compiling the library with clients.

# Navigate to clients binary directory
$ cd hipSPARSE/build/release/clients/staging

# Execute hipSPARSE example
$ ./example_csrmv 1000

Supported Targets

Currently, hipSPARSE is supported under the following operating systems

To compile and run hipSPARSE, AMD ROCm Platform is required.

Device and Stream Management

hipSetDevice() and hipGetDevice() are HIP device management APIs. They are NOT part of the hipSPARSE API.

Asynchronous Execution

All hipSPARSE library functions, unless otherwise stated, are non blocking and executed asynchronously with respect to the host. They may return before the actual computation has finished. To force synchronization, hipDeviceSynchronize() or hipStreamSynchronize() can be used. This will ensure that all previously executed hipSPARSE functions on the device / this particular stream have completed.

HIP Device Management

Before a HIP kernel invocation, users need to call hipSetDevice() to set a device, e.g. device 1. If users do not explicitly call it, the system by default sets it as device 0. Unless users explicitly call hipSetDevice() to set to another device, their HIP kernels are always launched on device 0.

The above is a HIP (and CUDA) device management approach and has nothing to do with hipSPARSE. hipSPARSE honors the approach above and assumes users have already set the device before a hipSPARSE routine call.

Once users set the device, they create a handle with hipsparseCreate().

Subsequent hipSPARSE routines take this handle as an input parameter. hipSPARSE ONLY queries (by hipGetDevice()) the user’s device; hipSPARSE does NOT set the device for users. If hipSPARSE does not see a valid device, it returns an error message. It is the users’ responsibility to provide a valid device to hipSPARSE and ensure the device safety.

Users CANNOT switch devices between hipsparseCreate() and hipsparseDestroy(). If users want to change device, they must destroy the current handle and create another hipSPARSE handle.

HIP Stream Management

HIP kernels are always launched in a queue (also known as stream).

If users do not explicitly specify a stream, the system provides a default stream, maintained by the system. Users cannot create or destroy the default stream. However, users can freely create new streams (with hipStreamCreate()) and bind it to the hipSPARSE handle using hipsparseGetVersion(). HIP kernels are invoked in hipSPARSE routines. The hipSPARSE handle is always associated with a stream, and hipSPARSE passes its stream to the kernels inside the routine. One hipSPARSE routine only takes one stream in a single invocation. If users create a stream, they are responsible for destroying it.

Multiple Streams and Multiple Devices

If the system under test has multiple HIP devices, users can run multiple hipSPARSE handles concurrently, but can NOT run a single hipSPARSE handle on different discrete devices. Each handle is associated with a particular singular device, and a new handle should be created for each additional device.

Storage Formats

COO storage format

The Coordinate (COO) storage format represents a \(m \times n\) matrix by

m

number of rows (integer).

n

number of columns (integer).

nnz

number of non-zero elements (integer).

coo_val

array of nnz elements containing the data (floating point).

coo_row_ind

array of nnz elements containing the row indices (integer).

coo_col_ind

array of nnz elements containing the column indices (integer).

The COO matrix is expected to be sorted by row indices and column indices per row. Furthermore, each pair of indices should appear only once. Consider the following \(3 \times 5\) matrix and the corresponding COO structures, with \(m = 3, n = 5\) and \(\text{nnz} = 8\) using zero based indexing:

\[\begin{split}A = \begin{pmatrix} 1.0 & 2.0 & 0.0 & 3.0 & 0.0 \\ 0.0 & 4.0 & 5.0 & 0.0 & 0.0 \\ 6.0 & 0.0 & 0.0 & 7.0 & 8.0 \\ \end{pmatrix}\end{split}\]

where

\[\begin{split}\begin{array}{ll} \text{coo_val}[8] & = \{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0\} \\ \text{coo_row_ind}[8] & = \{0, 0, 0, 1, 1, 2, 2, 2\} \\ \text{coo_col_ind}[8] & = \{0, 1, 3, 1, 2, 0, 3, 4\} \end{array}\end{split}\]

COO (AoS) storage format

The Coordinate (COO) Array of Structure (AoS) storage format represents a \(m \times n\) matrix by

m

number of rows (integer).

n

number of columns (integer).

nnz

number of non-zero elements (integer).

coo_val

array of nnz elements containing the data (floating point).

coo_ind

array of 2 * nnz elements containing alternating row and column indices (integer).

The COO (AoS) matrix is expected to be sorted by row indices and column indices per row. Furthermore, each pair of indices should appear only once. Consider the following \(3 \times 5\) matrix and the corresponding COO (AoS) structures, with \(m = 3, n = 5\) and \(\text{nnz} = 8\) using zero based indexing:

\[\begin{split}A = \begin{pmatrix} 1.0 & 2.0 & 0.0 & 3.0 & 0.0 \\ 0.0 & 4.0 & 5.0 & 0.0 & 0.0 \\ 6.0 & 0.0 & 0.0 & 7.0 & 8.0 \\ \end{pmatrix}\end{split}\]

where

\[\begin{split}\begin{array}{ll} \text{coo_val}[8] & = \{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0\} \\ \text{coo_ind}[16] & = \{0, 0, 0, 1, 0, 3, 1, 1, 1, 2, 2, 0, 2, 3, 2, 4\} \\ \end{array}\end{split}\]

CSR storage format

The Compressed Sparse Row (CSR) storage format represents a \(m \times n\) matrix by

m

number of rows (integer).

n

number of columns (integer).

nnz

number of non-zero elements (integer).

csr_val

array of nnz elements containing the data (floating point).

csr_row_ptr

array of m+1 elements that point to the start of every row (integer).

csr_col_ind

array of nnz elements containing the column indices (integer).

The CSR matrix is expected to be sorted by column indices within each row. Furthermore, each pair of indices should appear only once. Consider the following \(3 \times 5\) matrix and the corresponding CSR structures, with \(m = 3, n = 5\) and \(\text{nnz} = 8\) using one based indexing:

\[\begin{split}A = \begin{pmatrix} 1.0 & 2.0 & 0.0 & 3.0 & 0.0 \\ 0.0 & 4.0 & 5.0 & 0.0 & 0.0 \\ 6.0 & 0.0 & 0.0 & 7.0 & 8.0 \\ \end{pmatrix}\end{split}\]

where

\[\begin{split}\begin{array}{ll} \text{csr_val}[8] & = \{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0\} \\ \text{csr_row_ptr}[4] & = \{1, 4, 6, 9\} \\ \text{csr_col_ind}[8] & = \{1, 2, 4, 2, 3, 1, 4, 5\} \end{array}\end{split}\]

BSR storage format

The Block Compressed Sparse Row (BSR) storage format represents a \((mb \cdot \text{bsr_dim}) \times (nb \cdot \text{bsr_dim})\) matrix by

mb

number of block rows (integer)

nb

number of block columns (integer)

nnzb

number of non-zero blocks (integer)

bsr_val

array of nnzb * bsr_dim * bsr_dim elements containing the data (floating point). Blocks can be stored column-major or row-major.

bsr_row_ptr

array of mb+1 elements that point to the start of every block row (integer).

bsr_col_ind

array of nnzb elements containing the block column indices (integer).

bsr_dim

dimension of each block (integer).

The BSR matrix is expected to be sorted by column indices within each row. If \(m\) or \(n\) are not evenly divisible by the block dimension, then zeros are padded to the matrix, such that \(mb = (m + \text{bsr_dim} - 1) / \text{bsr_dim}\) and \(nb = (n + \text{bsr_dim} - 1) / \text{bsr_dim}\). Consider the following \(4 \times 3\) matrix and the corresponding BSR structures, with \(\text{bsr_dim} = 2, mb = 2, nb = 2\) and \(\text{nnzb} = 4\) using zero based indexing and column-major storage:

\[\begin{split}A = \begin{pmatrix} 1.0 & 0.0 & 2.0 \\ 3.0 & 0.0 & 4.0 \\ 5.0 & 6.0 & 0.0 \\ 7.0 & 0.0 & 8.0 \\ \end{pmatrix}\end{split}\]

with the blocks \(A_{ij}\)

\[\begin{split}A_{00} = \begin{pmatrix} 1.0 & 0.0 \\ 3.0 & 0.0 \\ \end{pmatrix}, A_{01} = \begin{pmatrix} 2.0 & 0.0 \\ 4.0 & 0.0 \\ \end{pmatrix}, A_{10} = \begin{pmatrix} 5.0 & 6.0 \\ 7.0 & 0.0 \\ \end{pmatrix}, A_{11} = \begin{pmatrix} 0.0 & 0.0 \\ 8.0 & 0.0 \\ \end{pmatrix}\end{split}\]

such that

\[\begin{split}A = \begin{pmatrix} A_{00} & A_{01} \\ A_{10} & A_{11} \\ \end{pmatrix}\end{split}\]

with arrays representation

\[\begin{split}\begin{array}{ll} \text{bsr_val}[16] & = \{1.0, 3.0, 0.0, 0.0, 2.0, 4.0, 0.0, 0.0, 5.0, 7.0, 6.0, 0.0, 0.0, 8.0, 0.0, 0.0\} \\ \text{bsr_row_ptr}[3] & = \{0, 2, 4\} \\ \text{bsr_col_ind}[4] & = \{0, 1, 0, 1\} \end{array}\end{split}\]

GEBSR storage format

The General Block Compressed Sparse Row (GEBSR) storage format represents a \((mb \cdot \text{bsr_row_dim}) \times (nb \cdot \text{bsr_col_dim})\) matrix by

mb

number of block rows (integer)

nb

number of block columns (integer)

nnzb

number of non-zero blocks (integer)

bsr_val

array of nnzb * bsr_row_dim * bsr_col_dim elements containing the data (floating point). Blocks can be stored column-major or row-major.

bsr_row_ptr

array of mb+1 elements that point to the start of every block row (integer).

bsr_col_ind

array of nnzb elements containing the block column indices (integer).

bsr_row_dim

row dimension of each block (integer).

bsr_col_dim

column dimension of each block (integer).

The GEBSR matrix is expected to be sorted by column indices within each row. If \(m\) is not evenly divisible by the row block dimension or \(n\) is not evenly divisible by the column block dimension, then zeros are padded to the matrix, such that \(mb = (m + \text{bsr_row_dim} - 1) / \text{bsr_row_dim}\) and \(nb = (n + \text{bsr_col_dim} - 1) / \text{bsr_col_dim}\). Consider the following \(4 \times 5\) matrix and the corresponding GEBSR structures, with \(\text{bsr_row_dim} = 2\), \(\text{bsr_col_dim} = 3\), mb = 2, nb = 2` and \(\text{nnzb} = 4\) using zero based indexing and column-major storage:

\[\begin{split}A = \begin{pmatrix} 1.0 & 0.0 & 0.0 & 2.0 & 0.0 \\ 3.0 & 0.0 & 4.0 & 0.0 & 0.0 \\ 5.0 & 6.0 & 0.0 & 7.0 & 0.0 \\ 0.0 & 0.0 & 8.0 & 0.0 & 9.0 \\ \end{pmatrix}\end{split}\]

with the blocks \(A_{ij}\)

\[\begin{split}A_{00} = \begin{pmatrix} 1.0 & 0.0 & 0.0 \\ 3.0 & 0.0 & 4.0 \\ \end{pmatrix}, A_{01} = \begin{pmatrix} 2.0 & 0.0 & 0.0 \\ 0.0 & 0.0 & 0.0 \\ \end{pmatrix}, A_{10} = \begin{pmatrix} 5.0 & 6.0 & 0.0 \\ 0.0 & 0.0 & 8.0 \\ \end{pmatrix}, A_{11} = \begin{pmatrix} 7.0 & 0.0 & 0.0 \\ 0.0 & 9.0 & 0.0 \\ \end{pmatrix}\end{split}\]

such that

\[\begin{split}A = \begin{pmatrix} A_{00} & A_{01} \\ A_{10} & A_{11} \\ \end{pmatrix}\end{split}\]

with arrays representation

\[\begin{split}\begin{array}{ll} \text{bsr_val}[24] & = \{1.0, 3.0, 0.0, 0.0, 0.0, 4.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 5.0, 0.0, 6.0, 0.0, 0.0, 8.0, 7.0, 0.0, 0.0, 9.0, 0.0, 0.0\} \\ \text{bsr_row_ptr}[3] & = \{0, 2, 4\} \\ \text{bsr_col_ind}[4] & = \{0, 1, 0, 1\} \end{array}\end{split}\]

ELL storage format

The Ellpack-Itpack (ELL) storage format represents a \(m \times n\) matrix by

m

number of rows (integer).

n

number of columns (integer).

ell_width

maximum number of non-zero elements per row (integer)

ell_val

array of m times ell_width elements containing the data (floating point).

ell_col_ind

array of m times ell_width elements containing the column indices (integer).

The ELL matrix is assumed to be stored in column-major format. Rows with less than ell_width non-zero elements are padded with zeros (ell_val) and \(-1\) (ell_col_ind). Consider the following \(3 \times 5\) matrix and the corresponding ELL structures, with \(m = 3, n = 5\) and \(\text{ell_width} = 3\) using zero based indexing:

\[\begin{split}A = \begin{pmatrix} 1.0 & 2.0 & 0.0 & 3.0 & 0.0 \\ 0.0 & 4.0 & 5.0 & 0.0 & 0.0 \\ 6.0 & 0.0 & 0.0 & 7.0 & 8.0 \\ \end{pmatrix}\end{split}\]

where

\[\begin{split}\begin{array}{ll} \text{ell_val}[9] & = \{1.0, 4.0, 6.0, 2.0, 5.0, 7.0, 3.0, 0.0, 8.0\} \\ \text{ell_col_ind}[9] & = \{0, 1, 0, 1, 2, 3, 3, -1, 4\} \end{array}\end{split}\]

HYB storage format

The Hybrid (HYB) storage format represents a \(m \times n\) matrix by

m

number of rows (integer).

n

number of columns (integer).

nnz

number of non-zero elements of the COO part (integer)

ell_width

maximum number of non-zero elements per row of the ELL part (integer)

ell_val

array of m times ell_width elements containing the ELL part data (floating point).

ell_col_ind

array of m times ell_width elements containing the ELL part column indices (integer).

coo_val

array of nnz elements containing the COO part data (floating point).

coo_row_ind

array of nnz elements containing the COO part row indices (integer).

coo_col_ind

array of nnz elements containing the COO part column indices (integer).

The HYB format is a combination of the ELL and COO sparse matrix formats. Typically, the regular part of the matrix is stored in ELL storage format, and the irregular part of the matrix is stored in COO storage format. Three different partitioning schemes can be applied when converting a CSR matrix to a matrix in HYB storage format. For further details on the partitioning schemes, see hipsparseHybPartition_t.

Types

hipsparseHandle_t

typedef void *hipsparseHandle_t

Handle to the hipSPARSE library context queue.

The hipSPARSE handle is a structure holding the hipSPARSE library context. It must be initialized using hipsparseCreate() and the returned handle must be passed to all subsequent library function calls. It should be destroyed at the end using hipsparseDestroy().

hipsparseMatDescr_t

typedef void *hipsparseMatDescr_t

Descriptor of the matrix.

The hipSPARSE matrix descriptor is a structure holding all properties of a matrix. It must be initialized using hipsparseCreateMatDescr() and the returned descriptor must be passed to all subsequent library calls that involve the matrix. It should be destroyed at the end using hipsparseDestroyMatDescr().

hipsparseHybMat_t

typedef void *hipsparseHybMat_t

HYB matrix storage format.

The hipSPARSE HYB matrix structure holds the HYB matrix. It must be initialized using hipsparseCreateHybMat() and the returned HYB matrix must be passed to all subsequent library calls that involve the matrix. It should be destroyed at the end using hipsparseDestroyHybMat().

For more details on the HYB format, see HYB storage format.

hipsparseColorInfo_t

typedef void *hipsparseColorInfo_t

Coloring info.

The hipSPARSE ColorInfo structure holds the coloring information. It must be initialized using hipsparseCreateColorInfo() and the returned structure must be passed to all subsequent library calls that involve the coloring. It should be destroyed at the end using hipsparseDestroyColorInfo().

bsrsv2Info_t

typedef struct bsrsv2Info *bsrsv2Info_t

bsrsm2Info_t

typedef struct bsrsm2Info *bsrsm2Info_t

bsrilu02Info_t

typedef struct bsrilu02Info *bsrilu02Info_t

bsric02Info_t

typedef struct bsric02Info *bsric02Info_t

csrsv2Info_t

typedef struct csrsv2Info *csrsv2Info_t

csrsm2Info_t

typedef struct csrsm2Info *csrsm2Info_t

csrilu02Info_t

typedef struct csrilu02Info *csrilu02Info_t

csric02Info_t

typedef struct csric02Info *csric02Info_t

csrgemm2Info_t

typedef struct csrgemm2Info *csrgemm2Info_t

pruneInfo_t

typedef struct pruneInfo *pruneInfo_t

csru2csrInfo_t

typedef struct csru2csrInfo *csru2csrInfo_t

hipsparseSpVecDescr_t

typedef void *hipsparseSpVecDescr_t

hipsparseSpMatDescr_t

typedef void *hipsparseSpMatDescr_t

hipsparseDnVecDescr_t

typedef void *hipsparseDnVecDescr_t

hipsparseDnMatDescr_t

typedef void *hipsparseDnMatDescr_t

hipsparseSpGEMMDescr_t

typedef struct hipsparseSpGEMMDescr *hipsparseSpGEMMDescr_t

hipsparseSpSVDescr_t

typedef struct hipsparseSpSVDescr *hipsparseSpSVDescr_t

hipsparseSpSMDescr_t

typedef struct hipsparseSpSMDescr *hipsparseSpSMDescr_t

hipsparseStatus_t

enum hipsparseStatus_t

List of hipsparse status codes definition.

This is a list of the hipsparseStatus_t types that are used by the hipSPARSE library.

Values:

enumerator HIPSPARSE_STATUS_SUCCESS
enumerator HIPSPARSE_STATUS_NOT_INITIALIZED
enumerator HIPSPARSE_STATUS_ALLOC_FAILED
enumerator HIPSPARSE_STATUS_INVALID_VALUE
enumerator HIPSPARSE_STATUS_ARCH_MISMATCH
enumerator HIPSPARSE_STATUS_MAPPING_ERROR
enumerator HIPSPARSE_STATUS_EXECUTION_FAILED
enumerator HIPSPARSE_STATUS_INTERNAL_ERROR
enumerator HIPSPARSE_STATUS_MATRIX_TYPE_NOT_SUPPORTED
enumerator HIPSPARSE_STATUS_ZERO_PIVOT
enumerator HIPSPARSE_STATUS_NOT_SUPPORTED
enumerator HIPSPARSE_STATUS_INSUFFICIENT_RESOURCES

hipsparsePointerMode_t

enum hipsparsePointerMode_t

Indicates if the pointer is device pointer or host pointer.

The hipsparsePointerMode_t indicates whether scalar values are passed by reference on the host or device. The hipsparsePointerMode_t can be changed by hipsparseSetPointerMode(). The currently used pointer mode can be obtained by hipsparseGetPointerMode().

Values:

enumerator HIPSPARSE_POINTER_MODE_HOST
enumerator HIPSPARSE_POINTER_MODE_DEVICE

hipsparseAction_t

enum hipsparseAction_t

Specify where the operation is performed on.

The hipsparseAction_t indicates whether the operation is performed on the full matrix, or only on the sparsity pattern of the matrix.

Values:

enumerator HIPSPARSE_ACTION_SYMBOLIC
enumerator HIPSPARSE_ACTION_NUMERIC

hipsparseMatrixType_t

enum hipsparseMatrixType_t

Specify the matrix type.

The hipsparseMatrixType_t indices the type of a matrix. For a given hipsparseMatDescr_t, the hipsparseMatrixType_t can be set using hipsparseSetMatType(). The current hipsparseMatrixType_t of a matrix can be obtained by hipsparseGetMatType().

Values:

enumerator HIPSPARSE_MATRIX_TYPE_GENERAL
enumerator HIPSPARSE_MATRIX_TYPE_SYMMETRIC
enumerator HIPSPARSE_MATRIX_TYPE_HERMITIAN
enumerator HIPSPARSE_MATRIX_TYPE_TRIANGULAR

hipsparseFillMode_t

enum hipsparseFillMode_t

Specify the matrix fill mode.

The hipsparseFillMode_t indicates whether the lower or the upper part is stored in a sparse triangular matrix. For a given hipsparseMatDescr_t, the hipsparseFillMode_t can be set using hipsparseSetMatFillMode(). The current hipsparseFillMode_t of a matrix can be obtained by hipsparseGetMatFillMode().

Values:

enumerator HIPSPARSE_FILL_MODE_LOWER
enumerator HIPSPARSE_FILL_MODE_UPPER

hipsparseDiagType_t

enum hipsparseDiagType_t

Indicates if the diagonal entries are unity.

The hipsparseDiagType_t indicates whether the diagonal entries of a matrix are unity or not. If HIPSPARSE_DIAG_TYPE_UNIT is specified, all present diagonal values will be ignored. For a given hipsparseMatDescr_t, the hipsparseDiagType_t can be set using hipsparseSetMatDiagType(). The current hipsparseDiagType_t of a matrix can be obtained by hipsparseGetMatDiagType().

Values:

enumerator HIPSPARSE_DIAG_TYPE_NON_UNIT
enumerator HIPSPARSE_DIAG_TYPE_UNIT

hipsparseIndexBase_t

enum hipsparseIndexBase_t

Specify the matrix index base.

The hipsparseIndexBase_t indicates the index base of the indices. For a given hipsparseMatDescr_t, the hipsparseIndexBase_t can be set using hipsparseSetMatIndexBase(). The current hipsparseIndexBase_t of a matrix can be obtained by hipsparseGetMatIndexBase().

Values:

enumerator HIPSPARSE_INDEX_BASE_ZERO
enumerator HIPSPARSE_INDEX_BASE_ONE

hipsparseOperation_t

enum hipsparseOperation_t

Specify whether the matrix is to be transposed or not.

The hipsparseOperation_t indicates the operation performed with the given matrix.

Values:

enumerator HIPSPARSE_OPERATION_NON_TRANSPOSE
enumerator HIPSPARSE_OPERATION_TRANSPOSE
enumerator HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE

hipsparseHybPartition_t

enum hipsparseHybPartition_t

HYB matrix partitioning type.

The hipsparseHybPartition_t type indicates how the hybrid format partitioning between COO and ELL storage formats is performed.

Values:

enumerator HIPSPARSE_HYB_PARTITION_AUTO
enumerator HIPSPARSE_HYB_PARTITION_USER
enumerator HIPSPARSE_HYB_PARTITION_MAX

hipsparseSolvePolicy_t

enum hipsparseSolvePolicy_t

Specify policy in triangular solvers and factorizations.

The hipsparseSolvePolicy_t type indicates the solve policy for the triangular solve.

Values:

enumerator HIPSPARSE_SOLVE_POLICY_NO_LEVEL
enumerator HIPSPARSE_SOLVE_POLICY_USE_LEVEL

hipsparseSideMode_t

enum hipsparseSideMode_t

Values:

enumerator HIPSPARSE_SIDE_LEFT
enumerator HIPSPARSE_SIDE_RIGHT

hipsparseDirection_t

enum hipsparseDirection_t

Specify the matrix direction.

The hipsparseDirection_t indicates whether a dense matrix should be parsed by rows or by columns, assuming column-major storage.

Values:

enumerator HIPSPARSE_DIRECTION_ROW
enumerator HIPSPARSE_DIRECTION_COLUMN

hipsparseFormat_t

enum hipsparseFormat_t

Values:

enumerator HIPSPARSE_FORMAT_CSR
enumerator HIPSPARSE_FORMAT_CSC
enumerator HIPSPARSE_FORMAT_COO
enumerator HIPSPARSE_FORMAT_COO_AOS
enumerator HIPSPARSE_FORMAT_BLOCKED_ELL

hipsparseOrder_t

enum hipsparseOrder_t

Values:

enumerator HIPSPARSE_ORDER_ROW
enumerator HIPSPARSE_ORDER_COLUMN

hipsparseIndextype_t

enum hipsparseIndexType_t

Values:

enumerator HIPSPARSE_INDEX_16U
enumerator HIPSPARSE_INDEX_32I
enumerator HIPSPARSE_INDEX_64I

hipsparseSpMVAlg_t

enum hipsparseSpMVAlg_t

Values:

enumerator HIPSPARSE_MV_ALG_DEFAULT
enumerator HIPSPARSE_COOMV_ALG
enumerator HIPSPARSE_CSRMV_ALG1
enumerator HIPSPARSE_CSRMV_ALG2
enumerator HIPSPARSE_SPMV_ALG_DEFAULT
enumerator HIPSPARSE_SPMV_COO_ALG1
enumerator HIPSPARSE_SPMV_COO_ALG2
enumerator HIPSPARSE_SPMV_CSR_ALG1
enumerator HIPSPARSE_SPMV_CSR_ALG2

hipsparseSpMMAlg_t

enum hipsparseSpMMAlg_t

Values:

enumerator HIPSPARSE_MM_ALG_DEFAULT
enumerator HIPSPARSE_COOMM_ALG1
enumerator HIPSPARSE_COOMM_ALG2
enumerator HIPSPARSE_COOMM_ALG3
enumerator HIPSPARSE_CSRMM_ALG1
enumerator HIPSPARSE_SPMM_ALG_DEFAULT
enumerator HIPSPARSE_SPMM_COO_ALG1
enumerator HIPSPARSE_SPMM_COO_ALG2
enumerator HIPSPARSE_SPMM_COO_ALG3
enumerator HIPSPARSE_SPMM_COO_ALG4
enumerator HIPSPARSE_SPMM_CSR_ALG1
enumerator HIPSPARSE_SPMM_CSR_ALG2
enumerator HIPSPARSE_SPMM_BLOCKED_ELL_ALG1
enumerator HIPSPARSE_SPMM_CSR_ALG3

hipsparseSparseToDenseAlg_t

enum hipsparseSparseToDenseAlg_t

Values:

enumerator HIPSPARSE_SPARSETODENSE_ALG_DEFAULT

hipsparseDenseToSparseAlg_t

enum hipsparseDenseToSparseAlg_t

Values:

enumerator HIPSPARSE_DENSETOSPARSE_ALG_DEFAULT

hipsparseSDDMMAlg_t

enum hipsparseSDDMMAlg_t

Values:

enumerator HIPSPARSE_SDDMM_ALG_DEFAULT

hipsparseSpSVAlg_t

enum hipsparseSpSVAlg_t

Values:

enumerator HIPSPARSE_SPSV_ALG_DEFAULT

hipsparseSpSMAlg_t

enum hipsparseSpSMAlg_t

Values:

enumerator HIPSPARSE_SPSM_ALG_DEFAULT

hipsparseSpMatAttribute_t

enum hipsparseSpMatAttribute_t

Values:

enumerator HIPSPARSE_SPMAT_FILL_MODE
enumerator HIPSPARSE_SPMAT_DIAG_TYPE

hipsparseSpGEMMAlg_t

enum hipsparseSpGEMMAlg_t

Values:

enumerator HIPSPARSE_SPGEMM_DEFAULT

Exported Sparse Functions

Auxiliary Functions

Function name

hipsparseCreate()

hipsparseDestroy()

hipsparseGetVersion()

hipsparseGetGitRevision()

hipsparseSetStream()

hipsparseGetStream()

hipsparseSetPointerMode()

hipsparseGetPointerMode()

hipsparseCreateMatDescr()

hipsparseDestroyMatDescr()

hipsparseCopyMatDescr()

hipsparseSetMatType()

hipsparseGetMatType()

hipsparseSetMatFillMode()

hipsparseGetMatFillMode()

hipsparseSetMatDiagType()

hipsparseGetMatDiagType()

hipsparseSetMatIndexBase()

hipsparseGetMatIndexBase()

hipsparseCreateHybMat()

hipsparseDestroyHybMat()

hipsparseCreateBsrsv2Info()

hipsparseDestroyBsrsv2Info()

hipsparseCreateBsrsm2Info()

hipsparseDestroyBsrsm2Info()

hipsparseCreateBsrilu02Info()

hipsparseDestroyBsrilu02Info()

hipsparseCreateBsric02Info()

hipsparseDestroyBsric02Info()

hipsparseCreateCsrsv2Info()

hipsparseDestroyCsrsv2Info()

hipsparseCreateCsrsm2Info()

hipsparseDestroyCsrsm2Info()

hipsparseCreateCsrilu02Info()

hipsparseDestroyCsrilu02Info()

hipsparseCreateCsric02Info()

hipsparseDestroyCsric02Info()

hipsparseCreateCsru2csrInfo()

hipsparseDestroyCsru2csrInfo()

hipsparseCreateColorInfo()

hipsparseDestroyColorInfo()

hipsparseCreateCsrgemm2Info()

hipsparseDestroyCsrgemm2Info()

hipsparseCreatePruneInfo()

hipsparseDestroyPruneInfo()

hipsparseCreateSpVec()

hipsparseDestroySpVec()

hipsparseSpVecGet()

hipsparseSpVecGetIndexBase()

hipsparseSpVecGetValues()

hipsparseSpVecSetValues()

hipsparseCreateCoo()

hipsparseCreateCooAoS()

hipsparseCreateCsr()

hipsparseCreateCsc()

hipsparseCreateBlockedEll()

hipsparseDestroySpMat()

hipsparseCooGet()

hipsparseCooAoSGet()

hipsparseCsrGet()

hipsparseBlockedEllGet()

hipsparseCsrSetPointers()

hipsparseCscSetPointers()

hipsparseCooSetPointers()

hipsparseSpMatGetSize()

hipsparseSpMatGetFormat()

hipsparseSpMatGetIndexBase()

hipsparseSpMatGetValues()

hipsparseSpMatSetValues()

hipsparseSpMatGetAttribute()

hipsparseSpMatSetAttribute()

hipsparseCreateDnVec()

hipsparseDestroyDnVec()

hipsparseDnVecGet()

hipsparseDnVecGetValues()

hipsparseDnVecSetValues()

hipsparseCreateDnMat()

hipsparseDestroyDnMat()

hipsparseDnMatGet()

hipsparseDnMatGetValues()

hipsparseDnMatSetValues()

Sparse Level 1 Functions

Function name

single

double

single complex

double complex

hipsparseXaxpyi()

x

x

x

x

hipsparseXdoti()

x

x

x

x

hipsparseXdotci()

x

x

hipsparseXgthr()

x

x

x

x

hipsparseXgthrz()

x

x

x

x

hipsparseXroti()

x

x

hipsparseXsctr()

x

x

x

x

Sparse Level 2 Functions

Function name

single

double

single complex

double complex

hipsparseXcsrmv()

x

x

x

x

hipsparseXcsrsv2_zeroPivot()

hipsparseXcsrsv2_bufferSize()

x

x

x

x

hipsparseXcsrsv2_bufferSizeExt()

x

x

x

x

hipsparseXcsrsv2_analysis()

x

x

x

x

hipsparseXcsrsv2_solve()

x

x

x

x

hipsparseXhybmv()

x

x

x

x

hipsparseXbsrmv()

x

x

x

x

hipsparseXbsrxmv()

x

x

x

x

hipsparseXbsrsv2_zeroPivot()

hipsparseXbsrsv2_bufferSize()

x

x

x

x

hipsparseXbsrsv2_bufferSizeExt()

x

x

x

x

hipsparseXbsrsv2_analysis()

x

x

x

x

hipsparseXbsrsv2_solve()

x

x

x

x

hipsparseXgemvi_bufferSize()

x

x

x

x

hipsparseXgemvi()

x

x

x

x

Sparse Level 3 Functions

Function name

single

double

single complex

double complex

hipsparseXbsrmm()

x

x

x

x

hipsparseXcsrmm()

x

x

x

x

hipsparseXcsrmm2()

x

x

x

x

hipsparseXbsrsm2_zeroPivot()

hipsparseXbsrsm2_bufferSize()

x

x

x

x

hipsparseXbsrsm2_analysis()

x

x

x

x

hipsparseXbsrsm2_solve()

x

x

x

x

hipsparseXcsrsm2_zeroPivot()

hipsparseXcsrsm2_bufferSizeExt()

x

x

x

x

hipsparseXcsrsm2_analysis()

x

x

x

x

hipsparseXcsrsm2_solve()

x

x

x

x

hipsparseXgemmi()

x

x

x

x

Sparse Extra Functions

Function name

single

double

single complex

double complex

hipsparseXcsrgeamNnz()

hipsparseXcsrgeam()

x

x

x

x

hipsparseXcsrgeam2_bufferSizeExt()

x

x

x

x

hipsparseXcsrgeam2Nnz()

hipsparseXcsrgeam2()

x

x

x

x

hipsparseXcsrgemmNnz()

hipsparseXcsrgemm()

x

x

x

x

hipsparseXcsrgemm2_bufferSizeExt()

x

x

x

x

hipsparseXcsrgemm2Nnz()

hipsparseXcsrgemm2()

x

x

x

x

Preconditioner Functions

Function name

single

double

single complex

double complex

hipsparseXbsrilu02_zeroPivot()

hipsparseXbsrilu02_numericBoost()

x

x

x

x

hipsparseXbsrilu02_bufferSize()

x

x

x

x

hipsparseXbsrilu02_analysis()

x

x

x

x

hipsparseXbsrilu02()

x

x

x

x

hipsparseXcsrilu02_zeroPivot()

hipsparseXcsrilu02_numericBoost()

x

x

x

x

hipsparseXcsrilu02_bufferSize()

x

x

x

x

hipsparseXcsrilu02_bufferSizeExt()

x

x

x

x

hipsparseXcsrilu02_analysis()

x

x

x

x

hipsparseXcsrilu02()

x

x

x

x

hipsparseXbsric02_zeroPivot()

hipsparseXbsric02_bufferSize()

x

x

x

x

hipsparseXbsric02_analysis()

x

x

x

x

hipsparseXbsric02()

x

x

x

x

hipsparseXcsric02_zeroPivot()

hipsparseXcsric02_bufferSize()

x

x

x

x

hipsparseXcsric02_bufferSizeExt()

x

x

x

x

hipsparseXcsric02_analysis()

x

x

x

x

hipsparseXcsric02()

x

x

x

x

hipsparseXgtsv2_bufferSizeExt()

x

x

x

x

hipsparseXgtsv2()

x

x

x

x

hipsparseXgtsv2_nopivot_bufferSizeExt()

x

x

x

x

hipsparseXgtsv2_nopivot()

x

x

x

x

hipsparseXgtsv2StridedBatch_bufferSizeExt()

x

x

x

x

hipsparseXgtsv2StridedBatch()

x

x

x

x

Conversion Functions

Function name

single

double

single complex

double complex

hipsparseXnnz()

x

x

x

x

hipsparseXdense2csr()

x

x

x

x

hipsparseXpruneDense2csr_bufferSize()

x

x

hipsparseXpruneDense2csrNnz()

x

x

hipsparseXpruneDense2csr()

x

x

hipsparseXpruneDense2csrByPercentage_bufferSize()

x

x

hipsparseXpruneDense2csrByPercentage_bufferSizeExt()

x

x

hipsparseXpruneDense2csrNnzByPercentage()

x

x

hipsparseXpruneDense2csrByPercentage()

x

x

hipsparseXdense2csc()

x

x

x

x

hipsparseXcsr2dense()

x

x

x

x

hipsparseXcsc2dense()

x

x

x

x

hipsparseXcsr2bsrNnz()

hipsparseXcsr2bsr()

x

x

x

x

hipsparseXnnz_compress()

x

x

x

x

hipsparseXcsr2coo()

hipsparseXcsr2csc()

x

x

x

x

hipsparseXcsr2hyb()

x

x

x

x

hipsparseXgebsr2gebsc_bufferSize

x

x

x

x

hipsparseXgebsr2gebsc()

x

x

x

x

hipsparseXcsr2gebsr_bufferSize()

x

x

x

x

hipsparseXcsr2gebsrNnz()

hipsparseXcsr2gebsr()

x

x

x

x

hipsparseXbsr2csr()

x

x

x

x

hipsparseXgebsr2csr()

x

x

x

x

hipsparseXcsr2csr_compress()

x

x

x

x

hipsparseXpruneCsr2csr_bufferSize()

x

x

hipsparseXpruneCsr2csr_bufferSizeExt()

x

x

hipsparseXpruneCsr2csrNnz()

x

x

hipsparseXpruneCsr2csr()

x

x

hipsparseXpruneCsr2csrByPercentage_bufferSize()

x

x

hipsparseXpruneCsr2csrByPercentage_bufferSizeExt()

x

x

hipsparseXpruneCsr2csrNnzByPercentage()

x

x

hipsparseXpruneCsr2csrByPercentage()

x

x

hipsparseXhyb2csr()

x

x

x

x

hipsparseXcoo2csr()

hipsparseCreateIdentityPermutation()

hipsparseXcsrsort_bufferSizeExt()

hipsparseXcsrsort()

hipsparseXcscsort_bufferSizeExt()

hipsparseXcscsort()

hipsparseXcoosort_bufferSizeExt()

hipsparseXcoosortByRow()

hipsparseXcoosortByColumn()

hipsparseXgebsr2gebsr_bufferSize()

x

x

x

x

hipsparseXgebsr2gebsrNnz()

hipsparseXgebsr2gebsr()

x

x

x

x

hipsparseXcsru2csr_bufferSizeExt()

x

x

x

x

hipsparseXcsru2csr()

x

x

x

x

hipsparseXcsr2csru()

x

x

x

x

Reordering Functions

Function name

single

double

single complex

double complex

hipsparseXcsrcolor()

x

x

x

x

Sparse Generic Functions

Function name

single

double

single complex

double complex

hipsparseAxpby()

x

x

x

x

hipsparseGather()

x

x

x

x

hipsparseScatter()

x

x

x

x

hipsparseRot()

x

x

x

x

hipsparseSparseToDense_bufferSize()

x

x

x

x

hipsparseSparseToDense()

x

x

x

x

hipsparseDenseToSparse_bufferSize()

x

x

x

x

hipsparseDenseToSparse_analysis()

x

x

x

x

hipsparseDenseToSparse_convert()

x

x

x

x

hipsparseSpVV_bufferSize()

x

x

x

x

hipsparseSpVV()

x

x

x

x

hipsparseSpMV_bufferSize()

x

x

x

x

hipsparseSpMV()

x

x

x

x

hipsparseSpMM_bufferSize()

x

x

x

x

hipsparseSpMM_preprocess()

x

x

x

x

hipsparseSpMM()

x

x

x

x

hipsparseSpGEMM_createDescr()

x

x

x

x

hipsparseSpGEMM_destroyDescr()

x

x

x

x

hipsparseSpGEMM_workEstimation()

x

x

x

x

hipsparseSpGEMM_compute()

x

x

x

x

hipsparseSpGEMM_copy()

x

x

x

x

hipsparseSDDMM_bufferSize()

x

x

x

x

hipsparseSDDMM_preprocess()

x

x

x

x

hipsparseSDDMM()

x

x

x

x

hipsparseSpSV_createDescr()

x

x

x

x

hipsparseSpSV_destroyDescr()

x

x

x

x

hipsparseSpSV_bufferSize()

x

x

x

x

hipsparseSpSV_analysis()

x

x

x

x

hipsparseSpSV_solve()

x

x

x

x

hipsparseSpSM_createDescr()

x

x

x

x

hipsparseSpSM_destroyDescr()

x

x

x

x

hipsparseSpSM_bufferSize()

x

x

x

x

hipsparseSpSM_analysis()

x

x

x

x

hipsparseSpSM_solve()

x

x

x

x

Storage schemes and indexing base

hipSPARSE supports 0 and 1 based indexing. The index base is selected by the hipsparseIndexBase_t type which is either passed as standalone parameter or as part of the hipsparseMatDescr_t type.

Furthermore, dense vectors are represented with a 1D array, stored linearly in memory. Sparse vectors are represented by a 1D data array stored linearly in memory that hold all non-zero elements and a 1D indexing array stored linearly in memory that hold the positions of the corresponding non-zero elements.

Pointer mode

The auxiliary functions hipsparseSetPointerMode() and hipsparseGetPointerMode() are used to set and get the value of the state variable hipsparsePointerMode_t. If hipsparsePointerMode_t is equal to HIPSPARSE_POINTER_MODE_HOST, then scalar parameters must be allocated on the host. If hipsparsePointerMode_t is equal to HIPSPARSE_POINTER_MODE_DEVICE, then scalar parameters must be allocated on the device.

There are two types of scalar parameter:

  1. Scaling parameters, such as alpha and beta used in e.g. hipsparseScsrmv(), hipsparseSbsrmv(), …

  2. Scalar results from functions such as hipsparseSdoti(), hipsparseCdotci(), …

For scalar parameters such as alpha and beta, memory can be allocated on the host heap or stack, when hipsparsePointerMode_t is equal to HIPSPARSE_POINTER_MODE_HOST. The kernel launch is asynchronous, and if the scalar parameter is on the heap, it can be freed after the return from the kernel launch. When hipsparsePointerMode_t is equal to HIPSPARSE_POINTER_MODE_DEVICE, the scalar parameter must not be changed till the kernel completes.

For scalar results, when hipsparsePointerMode_t is equal to HIPSPARSE_POINTER_MODE_HOST, the function blocks the CPU till the GPU has copied the result back to the host. Using hipsparsePointerMode_t equal to HIPSPARSE_POINTER_MODE_DEVICE, the function will return after the asynchronous launch. Similarly to vector and matrix results, the scalar result is only available when the kernel has completed execution.

Asynchronous API

Except a functions having memory allocation inside preventing asynchronicity, all hipSPARSE functions are configured to operate in non-blocking fashion with respect to CPU, meaning these library functions return immediately.

Sparse Auxiliary Functions

This module holds all sparse auxiliary functions.

The functions that are contained in the auxiliary module describe all available helper functions that are required for subsequent library calls.

hipsparseCreate()

hipsparseStatus_t hipsparseCreate(hipsparseHandle_t *handle)

Create a hipsparse handle.

hipsparseCreate creates the hipSPARSE library context. It must be initialized before any other hipSPARSE API function is invoked and must be passed to all subsequent library function calls. The handle should be destroyed at the end using hipsparseDestroy().

hipsparseDestroy()

hipsparseStatus_t hipsparseDestroy(hipsparseHandle_t handle)

Destroy a hipsparse handle.

hipsparseDestroy destroys the hipSPARSE library context and releases all resources used by the hipSPARSE library.

hipsparseGetVersion()

hipsparseStatus_t hipsparseGetVersion(hipsparseHandle_t handle, int *version)

Get hipSPARSE version.

hipsparseGetVersion gets the hipSPARSE library version number.

  • patch = version % 100

  • minor = version / 100 % 1000

  • major = version / 100000

hipsparseGetGitRevision()

hipsparseStatus_t hipsparseGetGitRevision(hipsparseHandle_t handle, char *rev)

Get hipSPARSE git revision.

hipsparseGetGitRevision gets the hipSPARSE library git commit revision (SHA-1).

hipsparseSetStream()

hipsparseStatus_t hipsparseSetStream(hipsparseHandle_t handle, hipStream_t streamId)

Specify user defined HIP stream.

hipsparseSetStream specifies the stream to be used by the hipSPARSE library context and all subsequent function calls.

hipsparseGetStream()

hipsparseStatus_t hipsparseGetStream(hipsparseHandle_t handle, hipStream_t *streamId)

Get current stream from library context.

hipsparseGetStream gets the hipSPARSE library context stream which is currently used for all subsequent function calls.

hipsparseSetPointerMode()

hipsparseStatus_t hipsparseSetPointerMode(hipsparseHandle_t handle, hipsparsePointerMode_t mode)

Specify pointer mode.

hipsparseSetPointerMode specifies the pointer mode to be used by the hipSPARSE library context and all subsequent function calls. By default, all values are passed by reference on the host. Valid pointer modes are HIPSPARSE_POINTER_MODE_HOST or HIPSPARSE_POINTER_MODE_DEVICE.

hipsparseGetPointerMode()

hipsparseStatus_t hipsparseGetPointerMode(hipsparseHandle_t handle, hipsparsePointerMode_t *mode)

Get current pointer mode from library context.

hipsparseGetPointerMode gets the hipSPARSE library context pointer mode which is currently used for all subsequent function calls.

hipsparseCreateMatDescr()

hipsparseStatus_t hipsparseCreateMatDescr(hipsparseMatDescr_t *descrA)

Create a matrix descriptor.

hipsparseCreateMatDescr creates a matrix descriptor. It initializes hipsparseMatrixType_t to HIPSPARSE_MATRIX_TYPE_GENERAL and hipsparseIndexBase_t to HIPSPARSE_INDEX_BASE_ZERO. It should be destroyed at the end using hipsparseDestroyMatDescr().

hipsparseDestroyMatDescr()

hipsparseStatus_t hipsparseDestroyMatDescr(hipsparseMatDescr_t descrA)

Destroy a matrix descriptor.

hipsparseDestroyMatDescr destroys a matrix descriptor and releases all resources used by the descriptor.

hipsparseCopyMatDescr()

hipsparseStatus_t hipsparseCopyMatDescr(hipsparseMatDescr_t dest, const hipsparseMatDescr_t src)

Copy a matrix descriptor.

hipsparseCopyMatDescr copies a matrix descriptor. Both, source and destination matrix descriptors must be initialized prior to calling hipsparseCopyMatDescr.

hipsparseSetMatType()

hipsparseStatus_t hipsparseSetMatType(hipsparseMatDescr_t descrA, hipsparseMatrixType_t type)

Specify the matrix type of a matrix descriptor.

hipsparseSetMatType sets the matrix type of a matrix descriptor. Valid matrix types are HIPSPARSE_MATRIX_TYPE_GENERAL, HIPSPARSE_MATRIX_TYPE_SYMMETRIC, HIPSPARSE_MATRIX_TYPE_HERMITIAN or HIPSPARSE_MATRIX_TYPE_TRIANGULAR.

hipsparseGetMatType()

hipsparseMatrixType_t hipsparseGetMatType(const hipsparseMatDescr_t descrA)

Get the matrix type of a matrix descriptor.

hipsparseGetMatType returns the matrix type of a matrix descriptor.

hipsparseSetMatFillMode()

hipsparseStatus_t hipsparseSetMatFillMode(hipsparseMatDescr_t descrA, hipsparseFillMode_t fillMode)

Specify the matrix fill mode of a matrix descriptor.

hipsparseSetMatFillMode sets the matrix fill mode of a matrix descriptor. Valid fill modes are HIPSPARSE_FILL_MODE_LOWER or HIPSPARSE_FILL_MODE_UPPER.

hipsparseGetMatFillMode()

hipsparseFillMode_t hipsparseGetMatFillMode(const hipsparseMatDescr_t descrA)

Get the matrix fill mode of a matrix descriptor.

hipsparseGetMatFillMode returns the matrix fill mode of a matrix descriptor.

hipsparseSetMatDiagType()

hipsparseStatus_t hipsparseSetMatDiagType(hipsparseMatDescr_t descrA, hipsparseDiagType_t diagType)

Specify the matrix diagonal type of a matrix descriptor.

hipsparseSetMatDiagType sets the matrix diagonal type of a matrix descriptor. Valid diagonal types are HIPSPARSE_DIAG_TYPE_UNIT or HIPSPARSE_DIAG_TYPE_NON_UNIT.

hipsparseGetMatDiagType()

hipsparseDiagType_t hipsparseGetMatDiagType(const hipsparseMatDescr_t descrA)

Get the matrix diagonal type of a matrix descriptor.

hipsparseGetMatDiagType returns the matrix diagonal type of a matrix descriptor.

hipsparseSetMatIndexBase()

hipsparseStatus_t hipsparseSetMatIndexBase(hipsparseMatDescr_t descrA, hipsparseIndexBase_t base)

Specify the index base of a matrix descriptor.

hipsparseSetMatIndexBase sets the index base of a matrix descriptor. Valid options are HIPSPARSE_INDEX_BASE_ZERO or HIPSPARSE_INDEX_BASE_ONE.

hipsparseGetMatIndexBase()

hipsparseIndexBase_t hipsparseGetMatIndexBase(const hipsparseMatDescr_t descrA)

Get the index base of a matrix descriptor.

hipsparseGetMatIndexBase returns the index base of a matrix descriptor.

hipsparseCreateHybMat()

hipsparseStatus_t hipsparseCreateHybMat(hipsparseHybMat_t *hybA)

Create a HYB matrix structure.

hipsparseCreateHybMat creates a structure that holds the matrix in HYB storage format. It should be destroyed at the end using hipsparseDestroyHybMat().

hipsparseDestroyHybMat()

hipsparseStatus_t hipsparseDestroyHybMat(hipsparseHybMat_t hybA)

Destroy a HYB matrix structure.

hipsparseDestroyHybMat destroys a HYB structure.

hipsparseCreateBsrsv2Info()

hipsparseStatus_t hipsparseCreateBsrsv2Info(bsrsv2Info_t *info)

Create a bsrsv2 info structure.

hipsparseCreateBsrsv2Info creates a structure that holds the bsrsv2 info data that is gathered during the analysis routines available. It should be destroyed at the end using hipsparseDestroyBsrsv2Info().

hipsparseDestroyBsrsv2Info()

hipsparseStatus_t hipsparseDestroyBsrsv2Info(bsrsv2Info_t info)

Destroy a bsrsv2 info structure.

hipsparseDestroyBsrsv2Info destroys a bsrsv2 info structure.

hipsparseCreateBsrsm2Info()

hipsparseStatus_t hipsparseCreateBsrsm2Info(bsrsm2Info_t *info)

Create a bsrsm2 info structure.

hipsparseCreateBsrsm2Info creates a structure that holds the bsrsm2 info data that is gathered during the analysis routines available. It should be destroyed at the end using hipsparseDestroyBsrsm2Info().

hipsparseDestroyBsrsm2Info()

hipsparseStatus_t hipsparseDestroyBsrsm2Info(bsrsm2Info_t info)

Destroy a bsrsm2 info structure.

hipsparseDestroyBsrsm2Info destroys a bsrsm2 info structure.

hipsparseCreateBsrilu02Info()

hipsparseStatus_t hipsparseCreateBsrilu02Info(bsrilu02Info_t *info)

Create a bsrilu02 info structure.

hipsparseCreateBsrilu02Info creates a structure that holds the bsrilu02 info data that is gathered during the analysis routines available. It should be destroyed at the end using hipsparseDestroyBsrilu02Info().

hipsparseDestroyBsrilu02Info()

hipsparseStatus_t hipsparseDestroyBsrilu02Info(bsrilu02Info_t info)

Destroy a bsrilu02 info structure.

hipsparseDestroyBsrilu02Info destroys a bsrilu02 info structure.

hipsparseCreateBsric02Info()

hipsparseStatus_t hipsparseCreateBsric02Info(bsric02Info_t *info)

Create a bsric02 info structure.

hipsparseCreateBsric02Info creates a structure that holds the bsric02 info data that is gathered during the analysis routines available. It should be destroyed at the end using hipsparseDestroyBsric02Info().

hipsparseDestroyBsric02Info()

hipsparseStatus_t hipsparseDestroyBsric02Info(bsric02Info_t info)

Destroy a bsric02 info structure.

hipsparseDestroyBsric02Info destroys a bsric02 info structure.

hipsparseCreateCsrsv2Info()

hipsparseStatus_t hipsparseCreateCsrsv2Info(csrsv2Info_t *info)

Create a csrsv2 info structure.

hipsparseCreateCsrsv2Info creates a structure that holds the csrsv2 info data that is gathered during the analysis routines available. It should be destroyed at the end using hipsparseDestroyCsrsv2Info().

hipsparseDestroyCsrsv2Info()

hipsparseStatus_t hipsparseDestroyCsrsv2Info(csrsv2Info_t info)

Destroy a csrsv2 info structure.

hipsparseDestroyCsrsv2Info destroys a csrsv2 info structure.

hipsparseCreateCsrsm2Info()

hipsparseStatus_t hipsparseCreateCsrsm2Info(csrsm2Info_t *info)

Create a csrsm2 info structure.

hipsparseCreateCsrsm2Info creates a structure that holds the csrsm2 info data that is gathered during the analysis routines available. It should be destroyed at the end using hipsparseDestroyCsrsm2Info().

hipsparseDestroyCsrsm2Info()

hipsparseStatus_t hipsparseDestroyCsrsm2Info(csrsm2Info_t info)

Destroy a csrsm2 info structure.

hipsparseDestroyCsrsm2Info destroys a csrsm2 info structure.

hipsparseCreateCsrilu02Info()

hipsparseStatus_t hipsparseCreateCsrilu02Info(csrilu02Info_t *info)

Create a csrilu02 info structure.

hipsparseCreateCsrilu02Info creates a structure that holds the csrilu02 info data that is gathered during the analysis routines available. It should be destroyed at the end using hipsparseDestroyCsrilu02Info().

hipsparseDestroyCsrilu02Info()

hipsparseStatus_t hipsparseDestroyCsrilu02Info(csrilu02Info_t info)

Destroy a csrilu02 info structure.

hipsparseDestroyCsrilu02Info destroys a csrilu02 info structure.

hipsparseCreateCsric02Info()

hipsparseStatus_t hipsparseCreateCsric02Info(csric02Info_t *info)

Create a csric02 info structure.

hipsparseCreateCsric02Info creates a structure that holds the csric02 info data that is gathered during the analysis routines available. It should be destroyed at the end using hipsparseDestroyCsric02Info().

hipsparseDestroyCsric02Info()

hipsparseStatus_t hipsparseDestroyCsric02Info(csric02Info_t info)

Destroy a csric02 info structure.

hipsparseDestroyCsric02Info destroys a csric02 info structure.

hipsparseCreateCsru2csrInfo()

hipsparseStatus_t hipsparseCreateCsru2csrInfo(csru2csrInfo_t *info)

Create a csru2csr info structure.

hipsparseCreateCsru2csrInfo creates a structure that holds the csru2csr info data that is gathered during the analysis routines available. It should be destroyed at the end using hipsparseDestroyCsru2csrInfo().

hipsparseDestroyCsru2csrInfo()

hipsparseStatus_t hipsparseDestroyCsru2csrInfo(csru2csrInfo_t info)

Destroy a csru2csr info structure.

hipsparseDestroyCsru2csrInfo destroys a csru2csr info structure.

hipsparseCreateColorInfo()

hipsparseStatus_t hipsparseCreateColorInfo(hipsparseColorInfo_t *info)

Create a color info structure.

hipsparseCreateColorInfo creates a structure that holds the color info data that is gathered during the analysis routines available. It should be destroyed at the end using hipsparseDestroyColorInfo().

hipsparseDestroyColorInfo()

hipsparseStatus_t hipsparseDestroyColorInfo(hipsparseColorInfo_t info)

Destroy a color info structure.

hipsparseDestroyColorInfo destroys a color info structure.

hipsparseCreateCsrgemm2Info()

hipsparseStatus_t hipsparseCreateCsrgemm2Info(csrgemm2Info_t *info)

Create a csrgemm2 info structure.

hipsparseCreateCsrgemm2Info creates a structure that holds the csrgemm2 info data that is gathered during the analysis routines available. It should be destroyed at the end using hipsparseDestroyCsrgemm2Info().

hipsparseDestroyCsrgemm2Info()

hipsparseStatus_t hipsparseDestroyCsrgemm2Info(csrgemm2Info_t info)

Destroy a csrgemm2 info structure.

hipsparseDestroyCsrgemm2Info destroys a csrgemm2 info structure.

hipsparseCreatePruneInfo()

hipsparseStatus_t hipsparseCreatePruneInfo(pruneInfo_t *info)

Create a prune info structure.

hipsparseCreatePruneInfo creates a structure that holds the prune info data that is gathered during the analysis routines available. It should be destroyed at the end using hipsparseDestroyPruneInfo().

hipsparseDestroyPruneInfo()

hipsparseStatus_t hipsparseDestroyPruneInfo(pruneInfo_t info)

Destroy a prune info structure.

hipsparseDestroyPruneInfo destroys a prune info structure.

hipsparseCreateSpVec()

hipsparseStatus_t hipsparseCreateSpVec(hipsparseSpVecDescr_t *spVecDescr, int64_t size, int64_t nnz, void *indices, void *values, hipsparseIndexType_t idxType, hipsparseIndexBase_t idxBase, hipDataType valueType)

hipsparseDestroySpVec()

hipsparseStatus_t hipsparseDestroySpVec(hipsparseSpVecDescr_t spVecDescr)

hipsparseSpVecGet()

hipsparseStatus_t hipsparseSpVecGet(const hipsparseSpVecDescr_t spVecDescr, int64_t *size, int64_t *nnz, void **indices, void **values, hipsparseIndexType_t *idxType, hipsparseIndexBase_t *idxBase, hipDataType *valueType)

hipsparseSpVecGetIndexBase()

hipsparseStatus_t hipsparseSpVecGetIndexBase(const hipsparseSpVecDescr_t spVecDescr, hipsparseIndexBase_t *idxBase)

hipsparseSpVecGetValues()

hipsparseStatus_t hipsparseSpVecGetValues(const hipsparseSpVecDescr_t spVecDescr, void **values)

hipsparseSpVecSetValues()

hipsparseStatus_t hipsparseSpVecSetValues(hipsparseSpVecDescr_t spVecDescr, void *values)

hipsparseCreateCoo()

hipsparseStatus_t hipsparseCreateCoo(hipsparseSpMatDescr_t *spMatDescr, int64_t rows, int64_t cols, int64_t nnz, void *cooRowInd, void *cooColInd, void *cooValues, hipsparseIndexType_t cooIdxType, hipsparseIndexBase_t idxBase, hipDataType valueType)

hipsparseCreateCooAoS()

hipsparseStatus_t hipsparseCreateCooAoS(hipsparseSpMatDescr_t *spMatDescr, int64_t rows, int64_t cols, int64_t nnz, void *cooInd, void *cooValues, hipsparseIndexType_t cooIdxType, hipsparseIndexBase_t idxBase, hipDataType valueType)

hipsparseCreateCsr()

hipsparseStatus_t hipsparseCreateCsr(hipsparseSpMatDescr_t *spMatDescr, int64_t rows, int64_t cols, int64_t nnz, void *csrRowOffsets, void *csrColInd, void *csrValues, hipsparseIndexType_t csrRowOffsetsType, hipsparseIndexType_t csrColIndType, hipsparseIndexBase_t idxBase, hipDataType valueType)

hipsparseCreateCsc()

hipsparseStatus_t hipsparseCreateCsc(hipsparseSpMatDescr_t *spMatDescr, int64_t rows, int64_t cols, int64_t nnz, void *cscColOffsets, void *cscRowInd, void *cscValues, hipsparseIndexType_t cscColOffsetsType, hipsparseIndexType_t cscRowIndType, hipsparseIndexBase_t idxBase, hipDataType valueType)

hipsparseCreateBlockedEll()

hipsparseStatus_t hipsparseCreateBlockedEll(hipsparseSpMatDescr_t *spMatDescr, int64_t rows, int64_t cols, int64_t ellBlockSize, int64_t ellCols, void *ellColInd, void *ellValue, hipsparseIndexType_t ellIdxType, hipsparseIndexBase_t idxBase, hipDataType valueType)

hipsparseDestroySpMat()

hipsparseStatus_t hipsparseDestroySpMat(hipsparseSpMatDescr_t spMatDescr)

hipsparseCooGet()

hipsparseStatus_t hipsparseCooGet(const hipsparseSpMatDescr_t spMatDescr, int64_t *rows, int64_t *cols, int64_t *nnz, void **cooRowInd, void **cooColInd, void **cooValues, hipsparseIndexType_t *idxType, hipsparseIndexBase_t *idxBase, hipDataType *valueType)

hipsparseCooAoSGet()

hipsparseStatus_t hipsparseCooAoSGet(const hipsparseSpMatDescr_t spMatDescr, int64_t *rows, int64_t *cols, int64_t *nnz, void **cooInd, void **cooValues, hipsparseIndexType_t *idxType, hipsparseIndexBase_t *idxBase, hipDataType *valueType)

hipsparseCsrGet()

hipsparseStatus_t hipsparseCsrGet(const hipsparseSpMatDescr_t spMatDescr, int64_t *rows, int64_t *cols, int64_t *nnz, void **csrRowOffsets, void **csrColInd, void **csrValues, hipsparseIndexType_t *csrRowOffsetsType, hipsparseIndexType_t *csrColIndType, hipsparseIndexBase_t *idxBase, hipDataType *valueType)

hipsparseBlockedEllGet()

hipsparseStatus_t hipsparseBlockedEllGet(const hipsparseSpMatDescr_t spMatDescr, int64_t *rows, int64_t *cols, int64_t *ellBlockSize, int64_t *ellCols, void **ellColInd, void **ellValue, hipsparseIndexType_t *ellIdxType, hipsparseIndexBase_t *idxBase, hipDataType *valueType)

hipsparseCsrSetPointers()

hipsparseStatus_t hipsparseCsrSetPointers(hipsparseSpMatDescr_t spMatDescr, void *csrRowOffsets, void *csrColInd, void *csrValues)

hipsparseCscSetPointers()

hipsparseStatus_t hipsparseCscSetPointers(hipsparseSpMatDescr_t spMatDescr, void *cscColOffsets, void *cscRowInd, void *cscValues)

hipsparseCooSetPointers()

hipsparseStatus_t hipsparseCooSetPointers(hipsparseSpMatDescr_t spMatDescr, void *cooRowInd, void *cooColInd, void *cooValues)

hipsparseSpMatGetSize()

hipsparseStatus_t hipsparseSpMatGetSize(hipsparseSpMatDescr_t spMatDescr, int64_t *rows, int64_t *cols, int64_t *nnz)

hipsparseSpMatGetFormat()

hipsparseStatus_t hipsparseSpMatGetFormat(const hipsparseSpMatDescr_t spMatDescr, hipsparseFormat_t *format)

hipsparseSpMatGetIndexBase()

hipsparseStatus_t hipsparseSpMatGetIndexBase(const hipsparseSpMatDescr_t spMatDescr, hipsparseIndexBase_t *idxBase)

hipsparseSpMatGetValues()

hipsparseStatus_t hipsparseSpMatGetValues(hipsparseSpMatDescr_t spMatDescr, void **values)

hipsparseSpMatSetValues()

hipsparseStatus_t hipsparseSpMatSetValues(hipsparseSpMatDescr_t spMatDescr, void *values)

hipsparseSpMatGetAttribute()

hipsparseStatus_t hipsparseSpMatGetAttribute(hipsparseSpMatDescr_t spMatDescr, hipsparseSpMatAttribute_t attribute, void *data, size_t dataSize)

hipsparseSpMatSetAttribute()

hipsparseStatus_t hipsparseSpMatSetAttribute(hipsparseSpMatDescr_t spMatDescr, hipsparseSpMatAttribute_t attribute, const void *data, size_t dataSize)

hipsparseCreateDnVec()

hipsparseStatus_t hipsparseCreateDnVec(hipsparseDnVecDescr_t *dnVecDescr, int64_t size, void *values, hipDataType valueType)

hipsparseDestroyDnVec()

hipsparseStatus_t hipsparseDestroyDnVec(hipsparseDnVecDescr_t dnVecDescr)

hipsparseDnVecGet()

hipsparseStatus_t hipsparseDnVecGet(const hipsparseDnVecDescr_t dnVecDescr, int64_t *size, void **values, hipDataType *valueType)

hipsparseDnVecGetValues()

hipsparseStatus_t hipsparseDnVecGetValues(const hipsparseDnVecDescr_t dnVecDescr, void **values)

hipsparseDnVecSetValues()

hipsparseStatus_t hipsparseDnVecSetValues(hipsparseDnVecDescr_t dnVecDescr, void *values)

hipsparseCreateDnMat()

hipsparseStatus_t hipsparseCreateDnMat(hipsparseDnMatDescr_t *dnMatDescr, int64_t rows, int64_t cols, int64_t ld, void *values, hipDataType valueType, hipsparseOrder_t order)

hipsparseDestroyDnMat()

hipsparseStatus_t hipsparseDestroyDnMat(hipsparseDnMatDescr_t dnMatDescr)

hipsparseDnMatGet()

hipsparseStatus_t hipsparseDnMatGet(const hipsparseDnMatDescr_t dnMatDescr, int64_t *rows, int64_t *cols, int64_t *ld, void **values, hipDataType *valueType, hipsparseOrder_t *order)

hipsparseDnMatGetValues()

hipsparseStatus_t hipsparseDnMatGetValues(const hipsparseDnMatDescr_t dnMatDescr, void **values)

hipsparseDnMatSetValues()

hipsparseStatus_t hipsparseDnMatSetValues(hipsparseDnMatDescr_t dnMatDescr, void *values)

Sparse Level 1 Functions

The sparse level 1 routines describe operations between a vector in sparse format and a vector in dense format. This section describes all hipSPARSE level 1 sparse linear algebra functions.

hipsparseXaxpyi()

hipsparseStatus_t hipsparseSaxpyi(hipsparseHandle_t handle, int nnz, const float *alpha, const float *xVal, const int *xInd, float *y, hipsparseIndexBase_t idxBase)
hipsparseStatus_t hipsparseDaxpyi(hipsparseHandle_t handle, int nnz, const double *alpha, const double *xVal, const int *xInd, double *y, hipsparseIndexBase_t idxBase)
hipsparseStatus_t hipsparseCaxpyi(hipsparseHandle_t handle, int nnz, const hipComplex *alpha, const hipComplex *xVal, const int *xInd, hipComplex *y, hipsparseIndexBase_t idxBase)
hipsparseStatus_t hipsparseZaxpyi(hipsparseHandle_t handle, int nnz, const hipDoubleComplex *alpha, const hipDoubleComplex *xVal, const int *xInd, hipDoubleComplex *y, hipsparseIndexBase_t idxBase)

Scale a sparse vector and add it to a dense vector.

hipsparseXaxpyi multiplies the sparse vector \(x\) with scalar \(\alpha\) and adds the result to the dense vector \(y\), such that

\[ y := y + \alpha \cdot x \]

for(i = 0; i < nnz; ++i)
{
    y[x_ind[i]] = y[x_ind[i]] + alpha * x_val[i];
}

Note

This function is non blocking and executed asynchronously with respect to the host. It may return before the actual computation has finished.

hipsparseXdoti()

hipsparseStatus_t hipsparseSdoti(hipsparseHandle_t handle, int nnz, const float *xVal, const int *xInd, const float *y, float *result, hipsparseIndexBase_t idxBase)
hipsparseStatus_t hipsparseDdoti(hipsparseHandle_t handle, int nnz, const double *xVal, const int *xInd, const double *y, double *result, hipsparseIndexBase_t idxBase)
hipsparseStatus_t hipsparseCdoti(hipsparseHandle_t handle, int nnz, const hipComplex *xVal, const int *xInd, const hipComplex *y, hipComplex *result, hipsparseIndexBase_t idxBase)
hipsparseStatus_t hipsparseZdoti(hipsparseHandle_t handle, int nnz, const hipDoubleComplex *xVal, const int *xInd, const hipDoubleComplex *y, hipDoubleComplex *result, hipsparseIndexBase_t idxBase)

Compute the dot product of a sparse vector with a dense vector.

hipsparseXdoti computes the dot product of the sparse vector \(x\) with the dense vector \(y\), such that

\[ \text{result} := y^T x \]

for(i = 0; i < nnz; ++i)
{
    result += x_val[i] * y[x_ind[i]];
}

Note

This function is non blocking and executed asynchronously with respect to the host. It may return before the actual computation has finished.

hipsparseXdotci()

hipsparseStatus_t hipsparseCdotci(hipsparseHandle_t handle, int nnz, const hipComplex *xVal, const int *xInd, const hipComplex *y, hipComplex *result, hipsparseIndexBase_t idxBase)
hipsparseStatus_t hipsparseZdotci(hipsparseHandle_t handle, int nnz, const hipDoubleComplex *xVal, const int *xInd, const hipDoubleComplex *y, hipDoubleComplex *result, hipsparseIndexBase_t idxBase)

Compute the dot product of a complex conjugate sparse vector with a dense vector.

hipsparseXdotci computes the dot product of the complex conjugate sparse vector \(x\) with the dense vector \(y\), such that

\[ \text{result} := \bar{x}^H y \]

for(i = 0; i < nnz; ++i)
{
    result += conj(x_val[i]) * y[x_ind[i]];
}

Note

This function is non blocking and executed asynchronously with respect to the host. It may return before the actual computation has finished.

hipsparseXgthr()

hipsparseStatus_t hipsparseSgthr(hipsparseHandle_t handle, int nnz, const float *y, float *xVal, const int *xInd, hipsparseIndexBase_t idxBase)
hipsparseStatus_t hipsparseDgthr(hipsparseHandle_t handle, int nnz, const double *y, double *xVal, const int *xInd, hipsparseIndexBase_t idxBase)
hipsparseStatus_t hipsparseCgthr(hipsparseHandle_t handle, int nnz, const hipComplex *y, hipComplex *xVal, const int *xInd, hipsparseIndexBase_t idxBase)
hipsparseStatus_t hipsparseZgthr(hipsparseHandle_t handle, int nnz, const hipDoubleComplex *y, hipDoubleComplex *xVal, const int *xInd, hipsparseIndexBase_t idxBase)

Gather elements from a dense vector and store them into a sparse vector.

hipsparseXgthr gathers the elements that are listed in x_ind from the dense vector \(y\) and stores them in the sparse vector \(x\).

for(i = 0; i < nnz; ++i)
{
    x_val[i] = y[x_ind[i]];
}

Note

This function is non blocking and executed asynchronously with respect to the host. It may return before the actual computation has finished.

hipsparseXgthrz()

hipsparseStatus_t hipsparseSgthrz(hipsparseHandle_t handle, int nnz, float *y, float *xVal, const int *xInd, hipsparseIndexBase_t idxBase)
hipsparseStatus_t hipsparseDgthrz(hipsparseHandle_t handle, int nnz, double *y, double *xVal, const int *xInd, hipsparseIndexBase_t idxBase)
hipsparseStatus_t hipsparseCgthrz(hipsparseHandle_t handle, int nnz, hipComplex *y, hipComplex *xVal, const int *xInd, hipsparseIndexBase_t idxBase)
hipsparseStatus_t hipsparseZgthrz(hipsparseHandle_t handle, int nnz, hipDoubleComplex *y, hipDoubleComplex *xVal, const int *xInd, hipsparseIndexBase_t idxBase)

Gather and zero out elements from a dense vector and store them into a sparse vector.

hipsparseXgthrz gathers the elements that are listed in x_ind from the dense vector \(y\) and stores them in the sparse vector \(x\). The gathered elements in \(y\) are replaced by zero.

for(i = 0; i < nnz; ++i)
{
    x_val[i]    = y[x_ind[i]];
    y[x_ind[i]] = 0;
}

Note

This function is non blocking and executed asynchronously with respect to the host. It may return before the actual computation has finished.

hipsparseXroti()

hipsparseStatus_t hipsparseSroti(hipsparseHandle_t handle, int nnz, float *xVal, const int *xInd, float *y, const float *c, const float *s, hipsparseIndexBase_t idxBase)
hipsparseStatus_t hipsparseDroti(hipsparseHandle_t handle, int nnz, double *xVal, const int *xInd, double *y, const double *c, const double *s, hipsparseIndexBase_t idxBase)

Apply Givens rotation to a dense and a sparse vector.

hipsparseXroti applies the Givens rotation matrix \(G\) to the sparse vector \(x\) and the dense vector \(y\), where

\[\begin{split} G = \begin{pmatrix} c & s \\ -s & c \end{pmatrix} \end{split}\]

for(i = 0; i < nnz; ++i)
{
    x_tmp = x_val[i];
    y_tmp = y[x_ind[i]];

    x_val[i]    = c * x_tmp + s * y_tmp;
    y[x_ind[i]] = c * y_tmp - s * x_tmp;
}

Note

This function is non blocking and executed asynchronously with respect to the host. It may return before the actual computation has finished.

hipsparseXsctr()

hipsparseStatus_t hipsparseSsctr(hipsparseHandle_t handle, int nnz, const float *xVal, const int *xInd, float *y, hipsparseIndexBase_t idxBase)
hipsparseStatus_t hipsparseDsctr(hipsparseHandle_t handle, int nnz, const double *xVal, const int *xInd, double *y, hipsparseIndexBase_t idxBase)
hipsparseStatus_t hipsparseCsctr(hipsparseHandle_t handle, int nnz, const hipComplex *xVal, const int *xInd, hipComplex *y, hipsparseIndexBase_t idxBase)
hipsparseStatus_t hipsparseZsctr(hipsparseHandle_t handle, int nnz, const hipDoubleComplex *xVal, const int *xInd, hipDoubleComplex *y, hipsparseIndexBase_t idxBase)

Scatter elements from a dense vector across a sparse vector.

hipsparseXsctr scatters the elements that are listed in x_ind from the sparse vector \(x\) into the dense vector \(y\). Indices of \(y\) that are not listed in x_ind remain unchanged.

for(i = 0; i < nnz; ++i)
{
    y[x_ind[i]] = x_val[i];
}

Note

This function is non blocking and executed asynchronously with respect to the host. It may return before the actual computation has finished.

Sparse Level 2 Functions

This module holds all sparse level 2 routines.

The sparse level 2 routines describe operations between a matrix in sparse format and a vector in dense format.

hipsparseXcsrmv()

hipsparseStatus_t hipsparseScsrmv(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int n, int nnz, const float *alpha, const hipsparseMatDescr_t descrA, const float *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, const float *x, const float *beta, float *y)
hipsparseStatus_t hipsparseDcsrmv(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int n, int nnz, const double *alpha, const hipsparseMatDescr_t descrA, const double *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, const double *x, const double *beta, double *y)
hipsparseStatus_t hipsparseCcsrmv(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int n, int nnz, const hipComplex *alpha, const hipsparseMatDescr_t descrA, const hipComplex *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, const hipComplex *x, const hipComplex *beta, hipComplex *y)
hipsparseStatus_t hipsparseZcsrmv(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int n, int nnz, const hipDoubleComplex *alpha, const hipsparseMatDescr_t descrA, const hipDoubleComplex *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, const hipDoubleComplex *x, const hipDoubleComplex *beta, hipDoubleComplex *y)

Sparse matrix vector multiplication using CSR storage format.

hipsparseXcsrmv multiplies the scalar \(\alpha\) with a sparse \(m \times n\) matrix, defined in CSR storage format, and the dense vector \(x\) and adds the result to the dense vector \(y\) that is multiplied by the scalar \(\beta\), such that

\[ y := \alpha \cdot op(A) \cdot x + \beta \cdot y, \]
with
\[\begin{split} op(A) = \left\{ \begin{array}{ll} A, & \text{if trans == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ A^T, & \text{if trans == HIPSPARSE_OPERATION_TRANSPOSE} \\ A^H, & \text{if trans == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} \end{array} \right. \end{split}\]

for(i = 0; i < m; ++i)
{
    y[i] = beta * y[i];

    for(j = csr_row_ptr[i]; j < csr_row_ptr[i + 1]; ++j)
    {
        y[i] = y[i] + alpha * csr_val[j] * x[csr_col_ind[j]];
    }
}

Note

This function is non blocking and executed asynchronously with respect to the host. It may return before the actual computation has finished.

Note

Currently, only trans == HIPSPARSE_OPERATION_NON_TRANSPOSE is supported.

hipsparseXcsrsv2_zeroPivot()

hipsparseStatus_t hipsparseXcsrsv2_zeroPivot(hipsparseHandle_t handle, csrsv2Info_t info, int *position)

Sparse triangular solve using CSR storage format.

hipsparseXcsrsv2_zeroPivot returns HIPSPARSE_STATUS_ZERO_PIVOT, if either a structural or numerical zero has been found during hipsparseScsrsv2_solve(), hipsparseDcsrsv2_solve(), hipsparseCcsrsv2_solve() or hipsparseZcsrsv2_solve() computation. The first zero pivot \(j\) at \(A_{j,j}\) is stored in position, using same index base as the CSR matrix.

position can be in host or device memory. If no zero pivot has been found, position is set to -1 and HIPSPARSE_STATUS_SUCCESS is returned instead.

Note

hipsparseXcsrsv2_zeroPivot is a blocking function. It might influence performance negatively.

hipsparseXcsrsv2_bufferSize()

hipsparseStatus_t hipsparseScsrsv2_bufferSize(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int nnz, const hipsparseMatDescr_t descrA, float *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, csrsv2Info_t info, int *pBufferSizeInBytes)
hipsparseStatus_t hipsparseDcsrsv2_bufferSize(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int nnz, const hipsparseMatDescr_t descrA, double *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, csrsv2Info_t info, int *pBufferSizeInBytes)
hipsparseStatus_t hipsparseCcsrsv2_bufferSize(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int nnz, const hipsparseMatDescr_t descrA, hipComplex *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, csrsv2Info_t info, int *pBufferSizeInBytes)
hipsparseStatus_t hipsparseZcsrsv2_bufferSize(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int nnz, const hipsparseMatDescr_t descrA, hipDoubleComplex *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, csrsv2Info_t info, int *pBufferSizeInBytes)

Sparse triangular solve using CSR storage format.

hipsparseXcsrsv2_bufferSize returns the size of the temporary storage buffer that is required by hipsparseScsrsv2_analysis(), hipsparseDcsrsv2_analysis(), hipsparseCcsrsv2_analysis(), hipsparseZcsrsv2_analysis(), hipsparseScsrsv2_solve(), hipsparseDcsrsv2_solve(), hipsparseCcsrsv2_solve() and hipsparseZcsrsv2_solve(). The temporary storage buffer must be allocated by the user.

hipsparseXcsrsv2_bufferSizeExt()

hipsparseStatus_t hipsparseScsrsv2_bufferSizeExt(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int nnz, const hipsparseMatDescr_t descrA, float *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, csrsv2Info_t info, size_t *pBufferSize)
hipsparseStatus_t hipsparseDcsrsv2_bufferSizeExt(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int nnz, const hipsparseMatDescr_t descrA, double *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, csrsv2Info_t info, size_t *pBufferSize)
hipsparseStatus_t hipsparseCcsrsv2_bufferSizeExt(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int nnz, const hipsparseMatDescr_t descrA, hipComplex *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, csrsv2Info_t info, size_t *pBufferSize)
hipsparseStatus_t hipsparseZcsrsv2_bufferSizeExt(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int nnz, const hipsparseMatDescr_t descrA, hipDoubleComplex *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, csrsv2Info_t info, size_t *pBufferSize)

Sparse triangular solve using CSR storage format.

hipsparseXcsrsv2_bufferSizeExt returns the size of the temporary storage buffer that is required by hipsparseScsrsv2_analysis(), hipsparseDcsrsv2_analysis(), hipsparseCcsrsv2_analysis(), hipsparseZcsrsv2_analysis(), hipsparseScsrsv2_solve(), hipsparseDcsrsv2_solve(), hipsparseCcsrsv2_solve() and hipsparseZcsrsv2_solve(). The temporary storage buffer must be allocated by the user.

hipsparseXcsrsv2_analysis()

hipsparseStatus_t hipsparseScsrsv2_analysis(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int nnz, const hipsparseMatDescr_t descrA, const float *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, csrsv2Info_t info, hipsparseSolvePolicy_t policy, void *pBuffer)
hipsparseStatus_t hipsparseDcsrsv2_analysis(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int nnz, const hipsparseMatDescr_t descrA, const double *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, csrsv2Info_t info, hipsparseSolvePolicy_t policy, void *pBuffer)
hipsparseStatus_t hipsparseCcsrsv2_analysis(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int nnz, const hipsparseMatDescr_t descrA, const hipComplex *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, csrsv2Info_t info, hipsparseSolvePolicy_t policy, void *pBuffer)
hipsparseStatus_t hipsparseZcsrsv2_analysis(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int nnz, const hipsparseMatDescr_t descrA, const hipDoubleComplex *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, csrsv2Info_t info, hipsparseSolvePolicy_t policy, void *pBuffer)

Sparse triangular solve using CSR storage format.

hipsparseXcsrsv2_analysis performs the analysis step for hipsparseScsrsv2_solve(), hipsparseDcsrsv2_solve(), hipsparseCcsrsv2_solve() and hipsparseZcsrsv2_solve().

Note

This function is non blocking and executed asynchronously with respect to the host. It may return before the actual computation has finished.

hipsparseXcsrsv2_solve()

hipsparseStatus_t hipsparseScsrsv2_solve(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int nnz, const float *alpha, const hipsparseMatDescr_t descrA, const float *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, csrsv2Info_t info, const float *f, float *x, hipsparseSolvePolicy_t policy, void *pBuffer)
hipsparseStatus_t hipsparseDcsrsv2_solve(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int nnz, const double *alpha, const hipsparseMatDescr_t descrA, const double *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, csrsv2Info_t info, const double *f, double *x, hipsparseSolvePolicy_t policy, void *pBuffer)
hipsparseStatus_t hipsparseCcsrsv2_solve(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int nnz, const hipComplex *alpha, const hipsparseMatDescr_t descrA, const hipComplex *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, csrsv2Info_t info, const hipComplex *f, hipComplex *x, hipsparseSolvePolicy_t policy, void *pBuffer)
hipsparseStatus_t hipsparseZcsrsv2_solve(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int nnz, const hipDoubleComplex *alpha, const hipsparseMatDescr_t descrA, const hipDoubleComplex *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, csrsv2Info_t info, const hipDoubleComplex *f, hipDoubleComplex *x, hipsparseSolvePolicy_t policy, void *pBuffer)

Sparse triangular solve using CSR storage format.

hipsparseXcsrsv2_solve solves a sparse triangular linear system of a sparse \(m \times m\) matrix, defined in CSR storage format, a dense solution vector \(y\) and the right-hand side \(x\) that is multiplied by \(\alpha\), such that

\[ op(A) \cdot y = \alpha \cdot x, \]
with
\[\begin{split} op(A) = \left\{ \begin{array}{ll} A, & \text{if trans == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ A^T, & \text{if trans == HIPSPARSE_OPERATION_TRANSPOSE} \\ A^H, & \text{if trans == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} \end{array} \right. \end{split}\]

hipsparseXcsrsv2_solve requires a user allocated temporary buffer. Its size is returned by hipsparseXcsrsv2_bufferSize() or hipsparseXcsrsv2_bufferSizeExt(). Furthermore, analysis meta data is required. It can be obtained by hipsparseXcsrsv2_analysis(). hipsparseXcsrsv2_solve reports the first zero pivot (either numerical or structural zero). The zero pivot status can be checked calling hipsparseXcsrsv2_zeroPivot(). If hipsparseDiagType_t == HIPSPARSE_DIAG_TYPE_UNIT, no zero pivot will be reported, even if \(A_{j,j} = 0\) for some \(j\).

Note

The sparse CSR matrix has to be sorted. This can be achieved by calling hipsparseXcsrsort().

Note

This function is non blocking and executed asynchronously with respect to the host. It may return before the actual computation has finished.

Note

Currently, only trans == HIPSPARSE_OPERATION_NON_TRANSPOSE and trans == HIPSPARSE_OPERATION_TRANSPOSE is supported.

hipsparseXhybmv()

hipsparseStatus_t hipsparseShybmv(hipsparseHandle_t handle, hipsparseOperation_t transA, const float *alpha, const hipsparseMatDescr_t descrA, const hipsparseHybMat_t hybA, const float *x, const float *beta, float *y)
hipsparseStatus_t hipsparseDhybmv(hipsparseHandle_t handle, hipsparseOperation_t transA, const double *alpha, const hipsparseMatDescr_t descrA, const hipsparseHybMat_t hybA, const double *x, const double *beta, double *y)
hipsparseStatus_t hipsparseChybmv(hipsparseHandle_t handle, hipsparseOperation_t transA, const hipComplex *alpha, const hipsparseMatDescr_t descrA, const hipsparseHybMat_t hybA, const hipComplex *x, const hipComplex *beta, hipComplex *y)
hipsparseStatus_t hipsparseZhybmv(hipsparseHandle_t handle, hipsparseOperation_t transA, const hipDoubleComplex *alpha, const hipsparseMatDescr_t descrA, const hipsparseHybMat_t hybA, const hipDoubleComplex *x, const hipDoubleComplex *beta, hipDoubleComplex *y)

Sparse matrix vector multiplication using HYB storage format.

hipsparseXhybmv multiplies the scalar \(\alpha\) with a sparse \(m \times n\) matrix, defined in HYB storage format, and the dense vector \(x\) and adds the result to the dense vector \(y\) that is multiplied by the scalar \(\beta\), such that

\[ y := \alpha \cdot op(A) \cdot x + \beta \cdot y, \]
with
\[\begin{split} op(A) = \left\{ \begin{array}{ll} A, & \text{if trans == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ A^T, & \text{if trans == HIPSPARSE_OPERATION_TRANSPOSE} \\ A^H, & \text{if trans == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} \end{array} \right. \end{split}\]

Note

This function is non blocking and executed asynchronously with respect to the host. It may return before the actual computation has finished.

Note

Currently, only trans == HIPSPARSE_OPERATION_NON_TRANSPOSE is supported.

hipsparseXbsrmv()

hipsparseStatus_t hipsparseSbsrmv(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, int mb, int nb, int nnzb, const float *alpha, const hipsparseMatDescr_t descrA, const float *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, const float *x, const float *beta, float *y)
hipsparseStatus_t hipsparseDbsrmv(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, int mb, int nb, int nnzb, const double *alpha, const hipsparseMatDescr_t descrA, const double *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, const double *x, const double *beta, double *y)
hipsparseStatus_t hipsparseCbsrmv(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, int mb, int nb, int nnzb, const hipComplex *alpha, const hipsparseMatDescr_t descrA, const hipComplex *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, const hipComplex *x, const hipComplex *beta, hipComplex *y)
hipsparseStatus_t hipsparseZbsrmv(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, int mb, int nb, int nnzb, const hipDoubleComplex *alpha, const hipsparseMatDescr_t descrA, const hipDoubleComplex *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, const hipDoubleComplex *x, const hipDoubleComplex *beta, hipDoubleComplex *y)

Sparse matrix vector multiplication using BSR storage format.

hipsparseXbsrmv multiplies the scalar \(\alpha\) with a sparse \((mb \cdot \text{block_dim}) \times (nb \cdot \text{block_dim})\) matrix, defined in BSR storage format, and the dense vector \(x\) and adds the result to the dense vector \(y\) that is multiplied by the scalar \(\beta\), such that

\[ y := \alpha \cdot op(A) \cdot x + \beta \cdot y, \]
with
\[\begin{split} op(A) = \left\{ \begin{array}{ll} A, & \text{if trans == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ A^T, & \text{if trans == HIPSPARSE_OPERATION_TRANSPOSE} \\ A^H, & \text{if trans == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} \end{array} \right. \end{split}\]

Note

This function is non blocking and executed asynchronously with respect to the host. It may return before the actual computation has finished.

Note

Currently, only trans == HIPSPARSE_OPERATION_NON_TRANSPOSE is supported.

hipsparseXbsrxmv()

hipsparseStatus_t hipsparseSbsrxmv(hipsparseHandle_t handle, hipsparseDirection_t dir, hipsparseOperation_t trans, int sizeOfMask, int mb, int nb, int nnzb, const float *alpha, const hipsparseMatDescr_t descr, const float *bsrVal, const int *bsrMaskPtr, const int *bsrRowPtr, const int *bsrEndPtr, const int *bsrColInd, int blockDim, const float *x, const float *beta, float *y)
hipsparseStatus_t hipsparseDbsrxmv(hipsparseHandle_t handle, hipsparseDirection_t dir, hipsparseOperation_t trans, int sizeOfMask, int mb, int nb, int nnzb, const double *alpha, const hipsparseMatDescr_t descr, const double *bsrVal, const int *bsrMaskPtr, const int *bsrRowPtr, const int *bsrEndPtr, const int *bsrColInd, int blockDim, const double *x, const double *beta, double *y)
hipsparseStatus_t hipsparseCbsrxmv(hipsparseHandle_t handle, hipsparseDirection_t dir, hipsparseOperation_t trans, int sizeOfMask, int mb, int nb, int nnzb, const hipComplex *alpha, const hipsparseMatDescr_t descr, const hipComplex *bsrVal, const int *bsrMaskPtr, const int *bsrRowPtr, const int *bsrEndPtr, const int *bsrColInd, int blockDim, const hipComplex *x, const hipComplex *beta, hipComplex *y)
hipsparseStatus_t hipsparseZbsrxmv(hipsparseHandle_t handle, hipsparseDirection_t dir, hipsparseOperation_t trans, int sizeOfMask, int mb, int nb, int nnzb, const hipDoubleComplex *alpha, const hipsparseMatDescr_t descr, const hipDoubleComplex *bsrVal, const int *bsrMaskPtr, const int *bsrRowPtr, const int *bsrEndPtr, const int *bsrColInd, int blockDim, const hipDoubleComplex *x, const hipDoubleComplex *beta, hipDoubleComplex *y)

Sparse matrix vector multiplication with mask operation using BSR storage format.

hipsparseXbsrxmv multiplies the scalar \(\alpha\) with a sparse \((mb \cdot \text{block_dim}) \times (nb \cdot \text{block_dim})\) modified matrix, defined in BSR storage format, and the dense vector \(x\) and adds the result to the dense vector \(y\) that is multiplied by the scalar \(\beta\), such that

\[ y := \left( \alpha \cdot op(A) \cdot x + \beta \cdot y \right)\left( \text{mask} \right), \]
with
\[\begin{split} op(A) = \left\{ \begin{array}{ll} A, & \text{if trans == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ A^T, & \text{if trans == HIPSPARSE_OPERATION_TRANSPOSE} \\ A^H, & \text{if trans == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} \end{array} \right. \end{split}\]

The \(\text{mask}\) is defined as an array of block row indices. The input sparse matrix is defined with a modified BSR storage format where the beginning and the end of each row is defined with two arrays, bsr_row_ptr and bsr_end_ptr (both of size mb), rather the usual bsr_row_ptr of size mb + 1.

Note

This function is non blocking and executed asynchronously with respect to the host. It may return before the actual computation has finished.

Note

Currently, only trans == HIPSPARSE_OPERATION_NON_TRANSPOSE is supported. Currently, block_dim == 1 is not supported.

hipsparseXbsrsv2_zeroPivot()

hipsparseStatus_t hipsparseXbsrsv2_zeroPivot(hipsparseHandle_t handle, bsrsv2Info_t info, int *position)

Sparse triangular solve using BSR storage format.

hipsparseXbsrsv2_zeroPivot returns HIPSPARSE_STATUS_ZERO_PIVOT, if either a structural or numerical zero has been found during hipsparseXbsrsv2_analysis() or hipsparseXbsrsv2_solve() computation. The first zero pivot \(j\) at \(A_{j,j}\) is stored in position, using same index base as the BSR matrix.

position can be in host or device memory. If no zero pivot has been found, position is set to -1 and HIPSPARSE_STATUS_SUCCESS is returned instead.

Note

hipsparseXbsrsv2_zeroPivot is a blocking function. It might influence performance negatively.

hipsparseXbsrsv2_bufferSize()

hipsparseStatus_t hipsparseSbsrsv2_bufferSize(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, int mb, int nnzb, const hipsparseMatDescr_t descrA, float *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, bsrsv2Info_t info, int *pBufferSizeInBytes)
hipsparseStatus_t hipsparseDbsrsv2_bufferSize(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, int mb, int nnzb, const hipsparseMatDescr_t descrA, double *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, bsrsv2Info_t info, int *pBufferSizeInBytes)
hipsparseStatus_t hipsparseCbsrsv2_bufferSize(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, int mb, int nnzb, const hipsparseMatDescr_t descrA, hipComplex *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, bsrsv2Info_t info, int *pBufferSizeInBytes)
hipsparseStatus_t hipsparseZbsrsv2_bufferSize(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, int mb, int nnzb, const hipsparseMatDescr_t descrA, hipDoubleComplex *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, bsrsv2Info_t info, int *pBufferSizeInBytes)

Sparse triangular solve using BSR storage format.

hipsparseXbsrsv2_bufferSize returns the size of the temporary storage buffer that is required by hipsparseXbsrsv2_analysis() and hipsparseXbsrsv2_solve(). The temporary storage buffer must be allocated by the user.

hipsparseXbsrsv2_bufferSizeExt()

hipsparseStatus_t hipsparseSbsrsv2_bufferSizeExt(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, int mb, int nnzb, const hipsparseMatDescr_t descrA, float *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, bsrsv2Info_t info, size_t *pBufferSize)
hipsparseStatus_t hipsparseDbsrsv2_bufferSizeExt(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, int mb, int nnzb, const hipsparseMatDescr_t descrA, double *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, bsrsv2Info_t info, size_t *pBufferSize)
hipsparseStatus_t hipsparseCbsrsv2_bufferSizeExt(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, int mb, int nnzb, const hipsparseMatDescr_t descrA, hipComplex *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, bsrsv2Info_t info, size_t *pBufferSize)
hipsparseStatus_t hipsparseZbsrsv2_bufferSizeExt(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, int mb, int nnzb, const hipsparseMatDescr_t descrA, hipDoubleComplex *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, bsrsv2Info_t info, size_t *pBufferSize)

Sparse triangular solve using BSR storage format.

hipsparseXbsrsv2_bufferSizeExt returns the size of the temporary storage buffer that is required by hipsparseXbsrsv2_analysis() and hipsparseXbsrsv2_solve(). The temporary storage buffer must be allocated by the user.

hipsparseXbsrsv2_analysis()

hipsparseStatus_t hipsparseSbsrsv2_analysis(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, int mb, int nnzb, const hipsparseMatDescr_t descrA, const float *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, bsrsv2Info_t info, hipsparseSolvePolicy_t policy, void *pBuffer)
hipsparseStatus_t hipsparseDbsrsv2_analysis(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, int mb, int nnzb, const hipsparseMatDescr_t descrA, const double *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, bsrsv2Info_t info, hipsparseSolvePolicy_t policy, void *pBuffer)
hipsparseStatus_t hipsparseCbsrsv2_analysis(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, int mb, int nnzb, const hipsparseMatDescr_t descrA, const hipComplex *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, bsrsv2Info_t info, hipsparseSolvePolicy_t policy, void *pBuffer)
hipsparseStatus_t hipsparseZbsrsv2_analysis(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, int mb, int nnzb, const hipsparseMatDescr_t descrA, const hipDoubleComplex *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, bsrsv2Info_t info, hipsparseSolvePolicy_t policy, void *pBuffer)

Sparse triangular solve using BSR storage format.

hipsparseXbsrsv2_analysis performs the analysis step for hipsparseXbsrsv2_solve().

Note

If the matrix sparsity pattern changes, the gathered information will become invalid.

Note

This function is non blocking and executed asynchronously with respect to the host. It may return before the actual computation has finished.

hipsparseXbsrsv2_solve()

hipsparseStatus_t hipsparseSbsrsv2_solve(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, int mb, int nnzb, const float *alpha, const hipsparseMatDescr_t descrA, const float *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, bsrsv2Info_t info, const float *f, float *x, hipsparseSolvePolicy_t policy, void *pBuffer)
hipsparseStatus_t hipsparseDbsrsv2_solve(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, int mb, int nnzb, const double *alpha, const hipsparseMatDescr_t descrA, const double *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, bsrsv2Info_t info, const double *f, double *x, hipsparseSolvePolicy_t policy, void *pBuffer)
hipsparseStatus_t hipsparseCbsrsv2_solve(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, int mb, int nnzb, const hipComplex *alpha, const hipsparseMatDescr_t descrA, const hipComplex *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, bsrsv2Info_t info, const hipComplex *f, hipComplex *x, hipsparseSolvePolicy_t policy, void *pBuffer)
hipsparseStatus_t hipsparseZbsrsv2_solve(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, int mb, int nnzb, const hipDoubleComplex *alpha, const hipsparseMatDescr_t descrA, const hipDoubleComplex *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, bsrsv2Info_t info, const hipDoubleComplex *f, hipDoubleComplex *x, hipsparseSolvePolicy_t policy, void *pBuffer)

Sparse triangular solve using BSR storage format.

hipsparseXbsrsv2_solve solves a sparse triangular linear system of a sparse \(m \times m\) matrix, defined in BSR storage format, a dense solution vector \(y\) and the right-hand side \(x\) that is multiplied by \(\alpha\), such that

\[ op(A) \cdot y = \alpha \cdot x, \]
with
\[\begin{split} op(A) = \left\{ \begin{array}{ll} A, & \text{if trans == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ A^T, & \text{if trans == HIPSPARSE_OPERATION_TRANSPOSE} \\ A^H, & \text{if trans == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} \end{array} \right. \end{split}\]

hipsparseXbsrsv2_solve requires a user allocated temporary buffer. Its size is returned by hipsparseXbsrsv2_bufferSize() or hipsparseXbsrsv2_bufferSizeExt(). Furthermore, analysis meta data is required. It can be obtained by hipsparseXbsrsv2_analysis(). hipsparseXbsrsv2_solve reports the first zero pivot (either numerical or structural zero). The zero pivot status can be checked calling hipsparseXbsrsv2_zeroPivot(). If hipsparseDiagType_t == HIPSPARSE_DIAG_TYPE_UNIT, no zero pivot will be reported, even if \(A_{j,j} = 0\) for some \(j\).

Note

The sparse BSR matrix has to be sorted.

Note

This function is non blocking and executed asynchronously with respect to the host. It may return before the actual computation has finished.

Note

Currently, only trans == HIPSPARSE_OPERATION_NON_TRANSPOSE and trans == HIPSPARSE_OPERATION_TRANSPOSE is supported.

hipsparseXgemvi_bufferSize()

hipsparseStatus_t hipsparseSgemvi_bufferSize(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int n, int nnz, int *pBufferSize)
hipsparseStatus_t hipsparseDgemvi_bufferSize(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int n, int nnz, int *pBufferSize)
hipsparseStatus_t hipsparseCgemvi_bufferSize(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int n, int nnz, int *pBufferSize)
hipsparseStatus_t hipsparseZgemvi_bufferSize(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int n, int nnz, int *pBufferSize)

Dense matrix sparse vector multiplication.

hipsparseXgemvi_bufferSize returns the size of the temporary storage buffer required by hipsparseXgemvi(). The temporary storage buffer must be allocated by the user.

hipsparseXgemvi()

hipsparseStatus_t hipsparseSgemvi(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int n, const float *alpha, const float *A, int lda, int nnz, const float *x, const int *xInd, const float *beta, float *y, hipsparseIndexBase_t idxBase, void *pBuffer)
hipsparseStatus_t hipsparseDgemvi(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int n, const double *alpha, const double *A, int lda, int nnz, const double *x, const int *xInd, const double *beta, double *y, hipsparseIndexBase_t idxBase, void *pBuffer)
hipsparseStatus_t hipsparseCgemvi(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int n, const hipComplex *alpha, const hipComplex *A, int lda, int nnz, const hipComplex *x, const int *xInd, const hipComplex *beta, hipComplex *y, hipsparseIndexBase_t idxBase, void *pBuffer)
hipsparseStatus_t hipsparseZgemvi(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int n, const hipDoubleComplex *alpha, const hipDoubleComplex *A, int lda, int nnz, const hipDoubleComplex *x, const int *xInd, const hipDoubleComplex *beta, hipDoubleComplex *y, hipsparseIndexBase_t idxBase, void *pBuffer)

Dense matrix sparse vector multiplication.

hipsparseXgemvi multiplies the scalar \(\alpha\) with a dense \(m \times n\) matrix \(A\) and the sparse vector \(x\) and adds the result to the dense vector \(y\) that is multiplied by the scalar \(\beta\), such that

\[ y := \alpha \cdot op(A) \cdot x + \beta \cdot y, \]
with
\[\begin{split} op(A) = \left\{ \begin{array}{ll} A, & \text{if trans == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ A^T, & \text{if trans == HIPSPARSE_OPERATION_TRANSPOSE} \\ A^H, & \text{if trans == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} \end{array} \right. \end{split}\]

hipsparseXgemvi requires a user allocated temporary buffer. Its size is returned by hipsparseXgemvi_bufferSize().

Note

This function is non blocking and executed asynchronously with respect to the host. It may return before the actual computation has finished.

Note

Currently, only trans == HIPSPARSE_OPERATION_NON_TRANSPOSE is supported.

Sparse Level 3 Functions

This module holds all sparse level 3 routines.

The sparse level 3 routines describe operations between a matrix in sparse format and multiple vectors in dense format that can also be seen as a dense matrix.

hipsparseXbsrmm()

hipsparseStatus_t hipsparseSbsrmm(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, hipsparseOperation_t transB, int mb, int n, int kb, int nnzb, const float *alpha, const hipsparseMatDescr_t descrA, const float *bsrValA, const int *bsrRowPtrA, const int *bsrColIndA, int blockDim, const float *B, int ldb, const float *beta, float *C, int ldc)
hipsparseStatus_t hipsparseDbsrmm(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, hipsparseOperation_t transB, int mb, int n, int kb, int nnzb, const double *alpha, const hipsparseMatDescr_t descrA, const double *bsrValA, const int *bsrRowPtrA, const int *bsrColIndA, int blockDim, const double *B, int ldb, const double *beta, double *C, int ldc)
hipsparseStatus_t hipsparseCbsrmm(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, hipsparseOperation_t transB, int mb, int n, int kb, int nnzb, const hipComplex *alpha, const hipsparseMatDescr_t descrA, const hipComplex *bsrValA, const int *bsrRowPtrA, const int *bsrColIndA, int blockDim, const hipComplex *B, int ldb, const hipComplex *beta, hipComplex *C, int ldc)
hipsparseStatus_t hipsparseZbsrmm(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, hipsparseOperation_t transB, int mb, int n, int kb, int nnzb, const hipDoubleComplex *alpha, const hipsparseMatDescr_t descrA, const hipDoubleComplex *bsrValA, const int *bsrRowPtrA, const int *bsrColIndA, int blockDim, const hipDoubleComplex *B, int ldb, const hipDoubleComplex *beta, hipDoubleComplex *C, int ldc)

Sparse matrix dense matrix multiplication using BSR storage format.

hipsparseXbsrmm multiplies the scalar \(\alpha\) with a sparse \(mb \times kb\) matrix \(A\), defined in BSR storage format, and the dense \(k \times n\) matrix \(B\) (where \(k = block\_dim \times kb\)) and adds the result to the dense \(m \times n\) matrix \(C\) (where \(m = block\_dim \times mb\)) that is multiplied by the scalar \(\beta\), such that

\[ C := \alpha \cdot op(A) \cdot op(B) + \beta \cdot C, \]
with
\[\begin{split} op(A) = \left\{ \begin{array}{ll} A, & \text{if trans_A == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ \end{array} \right. \end{split}\]
and
\[\begin{split} op(B) = \left\{ \begin{array}{ll} B, & \text{if trans_B == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ B^T, & \text{if trans_B == HIPSPARSE_OPERATION_TRANSPOSE} \\ \end{array} \right. \end{split}\]

Note

This function is non blocking and executed asynchronously with respect to the host. It may return before the actual computation has finished.

Note

Currently, only trans_A == HIPSPARSE_OPERATION_NON_TRANSPOSE is supported.

hipsparseXcsrmm()

hipsparseStatus_t hipsparseScsrmm(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int n, int k, int nnz, const float *alpha, const hipsparseMatDescr_t descrA, const float *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, const float *B, int ldb, const float *beta, float *C, int ldc)
hipsparseStatus_t hipsparseDcsrmm(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int n, int k, int nnz, const double *alpha, const hipsparseMatDescr_t descrA, const double *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, const double *B, int ldb, const double *beta, double *C, int ldc)
hipsparseStatus_t hipsparseCcsrmm(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int n, int k, int nnz, const hipComplex *alpha, const hipsparseMatDescr_t descrA, const hipComplex *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, const hipComplex *B, int ldb, const hipComplex *beta, hipComplex *C, int ldc)
hipsparseStatus_t hipsparseZcsrmm(hipsparseHandle_t handle, hipsparseOperation_t transA, int m, int n, int k, int nnz, const hipDoubleComplex *alpha, const hipsparseMatDescr_t descrA, const hipDoubleComplex *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, const hipDoubleComplex *B, int ldb, const hipDoubleComplex *beta, hipDoubleComplex *C, int ldc)

Sparse matrix dense matrix multiplication using CSR storage format.

hipsparseXcsrmm multiplies the scalar \(\alpha\) with a sparse \(m \times k\) matrix \(A\), defined in CSR storage format, and the dense \(k \times n\) matrix \(B\) and adds the result to the dense \(m \times n\) matrix \(C\) that is multiplied by the scalar \(\beta\), such that

\[ C := \alpha \cdot op(A) \cdot B + \beta \cdot C, \]
with
\[\begin{split} op(A) = \left\{ \begin{array}{ll} A, & \text{if trans_A == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ A^T, & \text{if trans_A == HIPSPARSE_OPERATION_TRANSPOSE} \\ A^H, & \text{if trans_A == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} \end{array} \right. \end{split}\]

for(i = 0; i < ldc; ++i)
{
    for(j = 0; j < n; ++j)
    {
        C[i][j] = beta * C[i][j];

        for(k = csr_row_ptr[i]; k < csr_row_ptr[i + 1]; ++k)
        {
            C[i][j] += alpha * csr_val[k] * B[csr_col_ind[k]][j];
        }
    }
}

Note

This function is non blocking and executed asynchronously with respect to the host. It may return before the actual computation has finished.

hipsparseXcsrmm2()

hipsparseStatus_t hipsparseScsrmm2(hipsparseHandle_t handle, hipsparseOperation_t transA, hipsparseOperation_t transB, int m, int n, int k, int nnz, const float *alpha, const hipsparseMatDescr_t descrA, const float *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, const float *B, int ldb, const float *beta, float *C, int ldc)
hipsparseStatus_t hipsparseDcsrmm2(hipsparseHandle_t handle, hipsparseOperation_t transA, hipsparseOperation_t transB, int m, int n, int k, int nnz, const double *alpha, const hipsparseMatDescr_t descrA, const double *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, const double *B, int ldb, const double *beta, double *C, int ldc)
hipsparseStatus_t hipsparseCcsrmm2(hipsparseHandle_t handle, hipsparseOperation_t transA, hipsparseOperation_t transB, int m, int n, int k, int nnz, const hipComplex *alpha, const hipsparseMatDescr_t descrA, const hipComplex *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, const hipComplex *B, int ldb, const hipComplex *beta, hipComplex *C, int ldc)
hipsparseStatus_t hipsparseZcsrmm2(hipsparseHandle_t handle, hipsparseOperation_t transA, hipsparseOperation_t transB, int m, int n, int k, int nnz, const hipDoubleComplex *alpha, const hipsparseMatDescr_t descrA, const hipDoubleComplex *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, const hipDoubleComplex *B, int ldb, const hipDoubleComplex *beta, hipDoubleComplex *C, int ldc)

Sparse matrix dense matrix multiplication using CSR storage format.

hipsparseXcsrmm2 multiplies the scalar \(\alpha\) with a sparse \(m \times k\) matrix \(A\), defined in CSR storage format, and the dense \(k \times n\) matrix \(B\) and adds the result to the dense \(m \times n\) matrix \(C\) that is multiplied by the scalar \(\beta\), such that

\[ C := \alpha \cdot op(A) \cdot op(B) + \beta \cdot C, \]
with
\[\begin{split} op(A) = \left\{ \begin{array}{ll} A, & \text{if trans_A == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ A^T, & \text{if trans_A == HIPSPARSE_OPERATION_TRANSPOSE} \\ A^H, & \text{if trans_A == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} \end{array} \right. \end{split}\]
and
\[\begin{split} op(B) = \left\{ \begin{array}{ll} B, & \text{if trans_B == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ B^T, & \text{if trans_B == HIPSPARSE_OPERATION_TRANSPOSE} \\ B^H, & \text{if trans_B == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} \end{array} \right. \end{split}\]

for(i = 0; i < ldc; ++i)
{
    for(j = 0; j < n; ++j)
    {
        C[i][j] = beta * C[i][j];

        for(k = csr_row_ptr[i]; k < csr_row_ptr[i + 1]; ++k)
        {
            C[i][j] += alpha * csr_val[k] * B[csr_col_ind[k]][j];
        }
    }
}

Note

This function is non blocking and executed asynchronously with respect to the host. It may return before the actual computation has finished.

hipsparseXbsrsm2_zeroPivot()

hipsparseStatus_t hipsparseXbsrsm2_zeroPivot(hipsparseHandle_t handle, bsrsm2Info_t info, int *position)

Sparse triangular system solve using BSR storage format.

hipsparseXbsrsm2_zeroPivot returns HIPSPARSE_STATUS_ZERO_PIVOT, if either a structural or numerical zero has been found during hipsparseXbsrsm2_analysis() or hipsparseXbsrsm2_solve() computation. The first zero pivot \(j\) at \(A_{j,j}\) is stored in position, using same index base as the BSR matrix.

position can be in host or device memory. If no zero pivot has been found, position is set to -1 and HIPSPARSE_STATUS_SUCCESS is returned instead.

Note

hipsparseXbsrsm2_zeroPivot is a blocking function. It might influence performance negatively.

hipsparseXbsrsm2_bufferSize()

hipsparseStatus_t hipsparseSbsrsm2_bufferSize(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, hipsparseOperation_t transX, int mb, int nrhs, int nnzb, const hipsparseMatDescr_t descrA, float *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, bsrsm2Info_t info, int *pBufferSizeInBytes)
hipsparseStatus_t hipsparseDbsrsm2_bufferSize(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, hipsparseOperation_t transX, int mb, int nrhs, int nnzb, const hipsparseMatDescr_t descrA, double *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, bsrsm2Info_t info, int *pBufferSizeInBytes)
hipsparseStatus_t hipsparseCbsrsm2_bufferSize(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, hipsparseOperation_t transX, int mb, int nrhs, int nnzb, const hipsparseMatDescr_t descrA, hipComplex *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, bsrsm2Info_t info, int *pBufferSizeInBytes)
hipsparseStatus_t hipsparseZbsrsm2_bufferSize(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, hipsparseOperation_t transX, int mb, int nrhs, int nnzb, const hipsparseMatDescr_t descrA, hipDoubleComplex *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, bsrsm2Info_t info, int *pBufferSizeInBytes)

Sparse triangular system solve using BSR storage format.

hipsparseXbsrsm2_buffer_size returns the size of the temporary storage buffer that is required by hipsparseXbsrsm2_analysis() and hipsparseXbsrsm2_solve(). The temporary storage buffer must be allocated by the user.

hipsparseXbsrsm2_analysis()

hipsparseStatus_t hipsparseSbsrsm2_analysis(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, hipsparseOperation_t transX, int mb, int nrhs, int nnzb, const hipsparseMatDescr_t descrA, const float *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, bsrsm2Info_t info, hipsparseSolvePolicy_t policy, void *pBuffer)
hipsparseStatus_t hipsparseDbsrsm2_analysis(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, hipsparseOperation_t transX, int mb, int nrhs, int nnzb, const hipsparseMatDescr_t descrA, const double *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, bsrsm2Info_t info, hipsparseSolvePolicy_t policy, void *pBuffer)
hipsparseStatus_t hipsparseCbsrsm2_analysis(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, hipsparseOperation_t transX, int mb, int nrhs, int nnzb, const hipsparseMatDescr_t descrA, const hipComplex *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, bsrsm2Info_t info, hipsparseSolvePolicy_t policy, void *pBuffer)
hipsparseStatus_t hipsparseZbsrsm2_analysis(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, hipsparseOperation_t transX, int mb, int nrhs, int nnzb, const hipsparseMatDescr_t descrA, const hipDoubleComplex *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, bsrsm2Info_t info, hipsparseSolvePolicy_t policy, void *pBuffer)

Sparse triangular system solve using BSR storage format.

hipsparseXbsrsm2_analysis performs the analysis step for hipsparseXbsrsm2_solve().

Note

If the matrix sparsity pattern changes, the gathered information will become invalid.

Note

This function is non blocking and executed asynchronously with respect to the host. It may return before the actual computation has finished.

hipsparseXbsrsm2_solve()

hipsparseStatus_t hipsparseSbsrsm2_solve(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, hipsparseOperation_t transX, int mb, int nrhs, int nnzb, const float *alpha, const hipsparseMatDescr_t descrA, const float *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, bsrsm2Info_t info, const float *B, int ldb, float *X, int ldx, hipsparseSolvePolicy_t policy, void *pBuffer)
hipsparseStatus_t hipsparseDbsrsm2_solve(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, hipsparseOperation_t transX, int mb, int nrhs, int nnzb, const double *alpha, const hipsparseMatDescr_t descrA, const double *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, bsrsm2Info_t info, const double *B, int ldb, double *X, int ldx, hipsparseSolvePolicy_t policy, void *pBuffer)
hipsparseStatus_t hipsparseCbsrsm2_solve(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, hipsparseOperation_t transX, int mb, int nrhs, int nnzb, const hipComplex *alpha, const hipsparseMatDescr_t descrA, const hipComplex *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, bsrsm2Info_t info, const hipComplex *B, int ldb, hipComplex *X, int ldx, hipsparseSolvePolicy_t policy, void *pBuffer)
hipsparseStatus_t hipsparseZbsrsm2_solve(hipsparseHandle_t handle, hipsparseDirection_t dirA, hipsparseOperation_t transA, hipsparseOperation_t transX, int mb, int nrhs, int nnzb, const hipDoubleComplex *alpha, const hipsparseMatDescr_t descrA, const hipDoubleComplex *bsrSortedValA, const int *bsrSortedRowPtrA, const int *bsrSortedColIndA, int blockDim, bsrsm2Info_t info, const hipDoubleComplex *B, int ldb, hipDoubleComplex *X, int ldx, hipsparseSolvePolicy_t policy, void *pBuffer)

Sparse triangular system solve using BSR storage format.

hipsparseXbsrsm2_solve solves a sparse triangular linear system of a sparse \(m \times m\) matrix, defined in BSR storage format, a dense solution matrix \(X\) and the right-hand side matrix \(B\) that is multiplied by \(\alpha\), such that

\[ op(A) \cdot op(X) = \alpha \cdot op(B), \]
with
\[\begin{split} op(A) = \left\{ \begin{array}{ll} A, & \text{if trans_A == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ A^T, & \text{if trans_A == HIPSPARSE_OPERATION_TRANSPOSE} \\ A^H, & \text{if trans_A == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} \end{array} \right. \end{split}\]
,
\[\begin{split} op(X) = \left\{ \begin{array}{ll} X, & \text{if trans_X == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ X^T, & \text{if trans_X == HIPSPARSE_OPERATION_TRANSPOSE} \\ X^H, & \text{if trans_X == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} \end{array} \right. \end{split}\]

hipsparseXbsrsm2_solve requires a user allocated temporary buffer. Its size is returned by hipsparseXbsrsm2_bufferSize(). Furthermore, analysis meta data is required. It can be obtained by hipsparseXbsrsm2_analysis(). hipsparseXbsrsm2_solve reports the first zero pivot (either numerical or structural zero). The zero pivot status can be checked calling hipsparseXbsrsm2_zeroPivot(). If hipsparseDiagType_t == HIPSPARSE_DIAG_TYPE_UNIT, no zero pivot will be reported, even if \(A_{j,j} = 0\) for some \(j\).

Note

The sparse BSR matrix has to be sorted.

Note

Operation type of B and X must match, if \(op(B)=B, op(X)=X\).

Note

This function is non blocking and executed asynchronously with respect to the host. It may return before the actual computation has finished.

Note

Currently, only trans_A != HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE and trans_X != HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE is supported.

hipsparseXcsrsm2_zeroPivot()

hipsparseStatus_t hipsparseXcsrsm2_zeroPivot(hipsparseHandle_t handle, csrsm2Info_t info, int *position)

Sparse triangular system solve using CSR storage format.

hipsparseXcsrsm2_zeroPivot returns HIPSPARSE_STATUS_ZERO_PIVOT, if either a structural or numerical zero has been found during hipsparseXcsrsm2_analysis() or hipsparseXcsrsm2_solve() computation. The first zero pivot \(j\) at \(A_{j,j}\) is stored in position, using same index base as the CSR matrix.

position can be in host or device memory. If no zero pivot has been found, position is set to -1 and HIPSPARSE_STATUS_SUCCESS is returned instead.

Note

hipsparseXcsrsm2_zeroPivot is a blocking function. It might influence performance negatively.

hipsparseXcsrsm2_bufferSizeExt()

hipsparseStatus_t hipsparseScsrsm2_bufferSizeExt(hipsparseHandle_t handle, int algo, hipsparseOperation_t transA, hipsparseOperation_t transB, int m, int nrhs, int nnz, const float *alpha, const hipsparseMatDescr_t descrA, const float *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, const float *B, int ldb, csrsm2Info_t info, hipsparseSolvePolicy_t policy, size_t *pBufferSize)
hipsparseStatus_t hipsparseDcsrsm2_bufferSizeExt(hipsparseHandle_t handle, int algo, hipsparseOperation_t transA, hipsparseOperation_t transB, int m, int nrhs, int nnz, const double *alpha, const hipsparseMatDescr_t descrA, const double *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, const double *B, int ldb, csrsm2Info_t info, hipsparseSolvePolicy_t policy, size_t *pBufferSize)
hipsparseStatus_t hipsparseCcsrsm2_bufferSizeExt(hipsparseHandle_t handle, int algo, hipsparseOperation_t transA, hipsparseOperation_t transB, int m, int nrhs, int nnz, const hipComplex *alpha, const hipsparseMatDescr_t descrA, const hipComplex *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, const hipComplex *B, int ldb, csrsm2Info_t info, hipsparseSolvePolicy_t policy, size_t *pBufferSize)
hipsparseStatus_t hipsparseZcsrsm2_bufferSizeExt(hipsparseHandle_t handle, int algo, hipsparseOperation_t transA, hipsparseOperation_t transB, int m, int nrhs, int nnz, const hipDoubleComplex *alpha, const hipsparseMatDescr_t descrA, const hipDoubleComplex *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, const hipDoubleComplex *B, int ldb, csrsm2Info_t info, hipsparseSolvePolicy_t policy, size_t *pBufferSize)

Sparse triangular system solve using BSR storage format.

hipsparseXbsrsm2_solve solves a sparse triangular linear system of a sparse \(m \times m\) matrix, defined in BSR storage format, a dense solution matrix \(X\) and the right-hand side matrix \(B\) that is multiplied by \(\alpha\), such that

\[ op(A) \cdot op(X) = \alpha \cdot op(B), \]
with
\[\begin{split} op(A) = \left\{ \begin{array}{ll} A, & \text{if trans_A == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ A^T, & \text{if trans_A == HIPSPARSE_OPERATION_TRANSPOSE} \\ A^H, & \text{if trans_A == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} \end{array} \right. \end{split}\]
,
\[\begin{split} op(X) = \left\{ \begin{array}{ll} X, & \text{if trans_X == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ X^T, & \text{if trans_X == HIPSPARSE_OPERATION_TRANSPOSE} \\ X^H, & \text{if trans_X == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} \end{array} \right. \end{split}\]

hipsparseXbsrsm2_solve requires a user allocated temporary buffer. Its size is returned by hipsparseXbsrsm2_bufferSize(). Furthermore, analysis meta data is required. It can be obtained by hipsparseXbsrsm2_analysis(). hipsparseXbsrsm2_solve reports the first zero pivot (either numerical or structural zero). The zero pivot status can be checked calling hipsparseXbsrsm2_zeroPivot(). If hipsparseDiagType_t == HIPSPARSE_DIAG_TYPE_UNIT, no zero pivot will be reported, even if \(A_{j,j} = 0\) for some \(j\).

Note

The sparse BSR matrix has to be sorted.

Note

Operation type of B and X must match, if \(op(B)=B, op(X)=X\).

Note

This function is non blocking and executed asynchronously with respect to the host. It may return before the actual computation has finished.

Note

Currently, only trans_A != HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE and trans_X != HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE is supported.

hipsparseXcsrsm2_analysis()

hipsparseStatus_t hipsparseScsrsm2_analysis(hipsparseHandle_t handle, int algo, hipsparseOperation_t transA, hipsparseOperation_t transB, int m, int nrhs, int nnz, const float *alpha, const hipsparseMatDescr_t descrA, const float *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, const float *B, int ldb, csrsm2Info_t info, hipsparseSolvePolicy_t policy, void *pBuffer)
hipsparseStatus_t hipsparseDcsrsm2_analysis(hipsparseHandle_t handle, int algo, hipsparseOperation_t transA, hipsparseOperation_t transB, int m, int nrhs, int nnz, const double *alpha, const hipsparseMatDescr_t descrA, const double *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, const double *B, int ldb, csrsm2Info_t info, hipsparseSolvePolicy_t policy, void *pBuffer)
hipsparseStatus_t hipsparseCcsrsm2_analysis(hipsparseHandle_t handle, int algo, hipsparseOperation_t transA, hipsparseOperation_t transB, int m, int nrhs, int nnz, const hipComplex *alpha, const hipsparseMatDescr_t descrA, const hipComplex *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, const hipComplex *B, int ldb, csrsm2Info_t info, hipsparseSolvePolicy_t policy, void *pBuffer)
hipsparseStatus_t hipsparseZcsrsm2_analysis(hipsparseHandle_t handle, int algo, hipsparseOperation_t transA, hipsparseOperation_t transB, int m, int nrhs, int nnz, const hipDoubleComplex *alpha, const hipsparseMatDescr_t descrA, const hipDoubleComplex *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, const hipDoubleComplex *B, int ldb, csrsm2Info_t info, hipsparseSolvePolicy_t policy, void *pBuffer)

Sparse triangular system solve using CSR storage format.

hipsparseXcsrsm2_analysis performs the analysis step for hipsparseXcsrsm2_solve().

Note

If the matrix sparsity pattern changes, the gathered information will become invalid.

Note

This function is non blocking and executed asynchronously with respect to the host. It may return before the actual computation has finished.

hipsparseXcsrsm2_solve()

hipsparseStatus_t hipsparseScsrsm2_solve(hipsparseHandle_t handle, int algo, hipsparseOperation_t transA, hipsparseOperation_t transB, int m, int nrhs, int nnz, const float *alpha, const hipsparseMatDescr_t descrA, const float *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, float *B, int ldb, csrsm2Info_t info, hipsparseSolvePolicy_t policy, void *pBuffer)
hipsparseStatus_t hipsparseDcsrsm2_solve(hipsparseHandle_t handle, int algo, hipsparseOperation_t transA, hipsparseOperation_t transB, int m, int nrhs, int nnz, const double *alpha, const hipsparseMatDescr_t descrA, const double *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, double *B, int ldb, csrsm2Info_t info, hipsparseSolvePolicy_t policy, void *pBuffer)
hipsparseStatus_t hipsparseCcsrsm2_solve(hipsparseHandle_t handle, int algo, hipsparseOperation_t transA, hipsparseOperation_t transB, int m, int nrhs, int nnz, const hipComplex *alpha, const hipsparseMatDescr_t descrA, const hipComplex *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, hipComplex *B, int ldb, csrsm2Info_t info, hipsparseSolvePolicy_t policy, void *pBuffer)
hipsparseStatus_t hipsparseZcsrsm2_solve(hipsparseHandle_t handle, int algo, hipsparseOperation_t transA, hipsparseOperation_t transB, int m, int nrhs, int nnz, const hipDoubleComplex *alpha, const hipsparseMatDescr_t descrA, const hipDoubleComplex *csrSortedValA, const int *csrSortedRowPtrA, const int *csrSortedColIndA, hipDoubleComplex *B, int ldb, csrsm2Info_t info, hipsparseSolvePolicy_t policy, void *pBuffer)

Sparse triangular system solve using CSR storage format.

hipsparseXcsrsm2_solve solves a sparse triangular linear system of a sparse \(m \times m\) matrix, defined in CSR storage format, a dense solution matrix \(X\) and the right-hand side matrix \(B\) that is multiplied by \(\alpha\), such that

\[ op(A) \cdot op(X) = \alpha \cdot op(B), \]
with
\[\begin{split} op(A) = \left\{ \begin{array}{ll} A, & \text{if trans_A == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ A^T, & \text{if trans_A == HIPSPARSE_OPERATION_TRANSPOSE} \\ A^H, & \text{if trans_A == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} \end{array} \right. \end{split}\]
,
\[\begin{split} op(B) = \left\{ \begin{array}{ll} B, & \text{if trans_B == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ B^T, & \text{if trans_B == HIPSPARSE_OPERATION_TRANSPOSE} \\ B^H, & \text{if trans_B == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} \end{array} \right. \end{split}\]
and
\[\begin{split} op(X) = \left\{ \begin{array}{ll} X, & \text{if trans_B == HIPSPARSE_OPERATION_NON_TRANSPOSE} \\ X^T, & \text{if trans_B == HIPSPARSE_OPERATION_TRANSPOSE} \\ X^H, & \text{if trans_B == HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE} \end{array} \right. \end{split}\]

hipsparseXcsrsm2_solve requires a user allocated temporary buffer. Its size is returned by hipsparseXcsrsm2_bufferSizeExt(). Furthermore, analysis meta data is required. It can be obtained by hipsparseXcsrsm2_analysis(). hipsparseXcsrsm2_solve reports the first zero pivot (either numerical or structural zero). The zero pivot status can be checked calling hipsparseXcsrsm2_zeroPivot(). If hipsparseDiagType_t == HIPSPARSE_DIAG_TYPE_UNIT, no zero pivot will be reported, even if \(A_{j,j} = 0\) for some \(j\).

Note

The sparse CSR matrix has to be sorted. This can be achieved by calling hipsparseXcsrsort().

Note

This function is non blocking and executed asynchronously with respect to the host. It may return before the actual computation has finished.

Note

Currently, only trans_A != HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE and trans_B != HIPSPARSE_OPERATION_CONJUGATE_TRANSPOSE is supported.

hipsparseXgemmi()

hipsparseStatus_t hipsparseSgemmi(hipsparseHandle_t handle, int m, int n, int k, int nnz, const float *alpha, const float *A, int lda, const float *cscValB, const int *cscColPtrB, const int *cscRowIndB, const float *beta, float *C, int ldc)
hipsparseStatus_t hipsparseDgemmi(hipsparseHandle_t handle, int m, int n, int k, int nnz, const double *alpha, const double *A, int lda, const double *cscValB, const int *cscColPtrB, const int *cscRowIndB, const double *beta, double *C, int ldc)
hipsparseStatus_t hipsparseCgemmi(hipsparseHandle_t handle, int m, int n, int k, int nnz, const hipComplex *alpha, const hipComplex *A, int lda, const hipComplex *cscValB, const int *cscColPtrB, const int *cscRowIndB, const hipComplex *beta, hipComplex *C, int ldc)
hipsparseStatus_t hipsparseZgemmi(hipsparseHandle_t handle, int m, int n, int k, int nnz, const hipDoubleComplex *alpha, const hipDoubleComplex *A, int lda, const hipDoubleComplex *cscValB, const int *cscColPtrB, const int *cscRowIndB,