oneapi::mkl::sparse::trsv#

Solves a system of linear equations for a triangular sparse matrix.

Description#

The oneapi::mkl::sparse::trsv routine solves the sparse triangular system

\[\text{op}(A)\cdot y = \alpha \cdot x\]

where \(A\) is a sparse triangular matrix of size \(m\) rows by \(m\) columns and \(\text{op()}\) is a matrix modifier:

\[\begin{split}\text{op}(A) = \begin{cases} A,& \text{ oneapi::mkl::transpose::nontrans}\\ A^{T},& \text{ oneapi::mkl::transpose::trans}\\A^{H},& \text{ oneapi::mkl::transpose::conjtrans} \end{cases}\end{split}\]

The dense vectors \(x\) and \(y\) must be at least of length \(m\). The vector \(x\) is input right hand side data and \(y\) is the resulting output vector.

For a given matrix decomposition into lower, diagonal, and upper parts \(A = L + D + U\), the triangular solve with one of oneapi::mkl::uplo::lower or oneapi::mkl::uplo::upper selected will perform the appropriate forward or backward substitution using respectively \(\text{op}(L+D)\) or \(\text{op}(D+U)\) for oneapi::mkl::diag::nonunit or, for oneapi::mkl::diag::unit, will perform the appropriate forward or backward substitution for \(\text{op}(L+I)\) or \(\text{op}(I+U)\) where \(I\) is the identity matrix.

Note

  • Refer to Sparse BLAS Supported Data and Integer Types for a list of supported <DATA_TYPE> and <INT_TYPE> data and integer types, and refer to Error Handling for a detailed description of the possible exceptions thrown.

  • While it can make sense to pass in the same array for both RHS (\(x\)) and solution (\(y\)) in order to update the RHS in-place, we currently do not support in-place sparse::trsv() operation.

API#

Syntax#

Using SYCL buffers:

namespace oneapi::mkl::sparse {
    void trsv (
        sycl::queue &queue,
        oneapi::mkl::uplo uplo_val,
        oneapi::mkl::transpose opA,
        oneapi::mkl::diag diag_val,
        const DATA_TYPE alpha,
        oneapi::mkl::sparse::matrix_handle_t A,
        sycl::buffer<DATA_TYPE, 1> &x,
        sycl::buffer<DATA_TYPE, 1> &y);

    [[deprecated("Use oneapi::mkl::sparse::trsv(queue, uplo_val, opA, diag_val, /* alpha */ 1.0, ...) instead.")]]
    void trsv (
        sycl::queue &queue,
        oneapi::mkl::uplo uplo_val,
        oneapi::mkl::transpose opA,
        oneapi::mkl::diag diag_val,
        oneapi::mkl::sparse::matrix_handle_t A,
        sycl::buffer<DATA_TYPE, 1> &x,
        sycl::buffer<DATA_TYPE, 1> &y);
}

Using USM pointers:

namespace oneapi::mkl::sparse {
    sycl::event trsv(
        sycl::queue &queue,
        oneapi::mkl::uplo uplo_val,
        oneapi::mkl::transpose opA,
        oneapi::mkl::diag diag_val,
        const DATA_TYPE alpha,
        oneapi::mkl::sparse::matrix_handle_t A,
        const DATA_TYPE *x,
        DATA_TYPE *y,
        const std::vector<sycl::event> &dependencies = {});

    [[deprecated("Use oneapi::mkl::sparse::trsv(queue, uplo_val, opA, diag_val, /* alpha */ 1.0, ...) instead.")]]
    sycl::event trsv(
        sycl::queue &queue,
        oneapi::mkl::uplo uplo_val,
        oneapi::mkl::transpose opA,
        oneapi::mkl::diag diag_val,
        const DATA_TYPE alpha,
        oneapi::mkl::sparse::matrix_handle_t A,
        const DATA_TYPE *x,
        DATA_TYPE *y,
        const std::vector<sycl::event> &dependencies = {});
}

Include Files#

  • oneapi/mkl/spblas.hpp

Input Parameters#

queue

Specifies the SYCL command queue that will be used for SYCL kernels execution.

uplo_val

Specifies which part of the matrix is to be processed.

oneapi::mkl::uplo::lower

The lower triangular matrix part is processed.

oneapi::mkl::uplo::upper

The upper triangular matrix part is processed.

opA

Specifies operation op() on input matrix.

oneapi::mkl::transpose::nontrans

Non-transpose, \(\text{op}(A) = A\).

oneapi::mkl::transpose::trans

Transpose, \(\text{op}(A) = A^{T}\).

oneapi::mkl::transpose::conjtrans

Conjugate transpose, \(\text{op}(A) = A^{H}\).

Note

Currently, the only supported case for operation is oneapi::mkl::transpose::nontrans.

diag_val

Specifies whether the diagonal used for computations is unit or based on provided matrix data.

oneapi::mkl::diag::nonunit

Diagonal elements are used as provided in the sparse matrix.

oneapi::mkl::diag::unit

The value of one is substituted for the diagonal elements in the triangular solve algorithm.

Note

If oneapi::mkl::diag::nonunit is selected, all diagonal values must be present in the sparse matrix sparsity profile and must not be zero valued. This is not necessary for the oneapi::mkl::diag::unit case. An exception of type onemkl::invalid_value() will be thrown in case this is violated.

alpha

Specifies the scalar, \(\alpha\).

A

Handle to object containing sparse matrix (A) and other internal data. Created using one of the oneapi::mkl::sparse::set_<sparse_matrix_type>_data routines.

Note

The supported cases for <sparse_matrix_type> are csr on CPU and GPU devices, and coo only on CPU device.

x

SYCL buffer or device-accessible USM pointer of size at least equal to the number of columns of input matrix if opA = oneapi::mkl::transpose::nontrans and at least the number of rows of input matrix otherwise. It is the input vector x

dependencies

A vector of type std::vector<sycl::event> containing the list of events that the oneapi::mkl::sparse::trsv routine depends on.

Output Parameters#

y

SYCL buffer or device-accessible USM pointer of size at least equal to the number of rows of the input matrix if opA = oneapi::mkl::transpose::nontrans and at least the number of columns of the input matrix otherwise. The solution of the triangular solve is filled into this array.

Return Values (USM Only)#

sycl::event

SYCL event that can be waited upon or added as a dependency for the completion of the trsv routine.

Examples#

An example of how to use oneapi::mkl::sparse::trsv with SYCL buffers or USM can be found in the oneMKL installation directory, under:

share/doc/mkl/examples/sycl/sparse_blas/source/csr_trsv.cpp
share/doc/mkl/examples/sycl/sparse_blas/source/csr_trsv_usm.cpp