oneapi::mkl::sparse::matmatd#

Computes a sparse matrix-sparse matrix product with a dense result.

Description#

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.

The oneapi::mkl::sparse::matmatd routine computes a sparse matrix-sparse matrix product with a dense matrix result defined as

\[C \leftarrow \alpha\cdot\text{op}(A)\cdot\text{op}(B) + \beta\cdot C\]

where: \(\alpha\) and \(\beta\) are scalars, \(A\) and \(B\) are sparse matrices, and \(C\) is a dense matrix of size c_nrows rows by c_ncols columns, and \(\text{op()}\) is a matrix modifier for A and B using the following description:

\[\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 matrix object C is stored with row-major or column-major layout. The sparse matrix objects A and B have an appropriate number of rows and columns for the matrix product.

API#

Syntax#

Using SYCL buffers:

namespace oneapi::mkl::sparse {
    void matmatd(sycl::queue &queue,
      oneapi::mkl::layout c_layout,
      oneapi::mkl::transpose opA,
      oneapi::mkl::transpose opB,
      const DATA_TYPE alpha,
      matrix_handle_t A,
      matrix_handle_t B,
      const DATA_TYPE beta,
      sycl::buffer<DATA_TYPE, 1> &C
      const std::int64_t c_nrows,
      const std::int64_t c_ncols,
      const std::int64_t ldc);
}

Using USM pointers:

namespace oneapi::mkl::sparse {
    sycl::event matmatd(
        sycl::queue &queue,
        oneapi::mkl::layout c_layout,
        oneapi::mkl::transpose opA,
        oneapi::mkl::transpose opB,
        const DATA_TYPE alpha,
        matrix_handle_t A,
        matrix_handle_t B,
        const DATA_TYPE beta,
        DATA_TYPE *C,
        const std::int64_t c_nrows,
        const std::int64_t c_ncols,
        const std::int64_t ldc,
        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.

c_layout

Specifies the storage scheme in memory for the dense matrix C.

opA

Specifies operation op() on input matrix A.

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}\).

opB

Specifies operation op() on input matrix B.

oneapi::mkl::transpose::nontrans

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

oneapi::mkl::transpose::trans

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

oneapi::mkl::transpose::conjtrans

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

alpha

Specifies the scalar, \(\alpha\).

A

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

Note

The ony currently supported case for <sparse_matrix_type> is csr.

B

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

Note

The ony currently supported case for <sparse_matrix_type> is csr.

beta

Specifies the scalar, \(\beta\).

C

SYCL buffer or device-accessible USM pointer of size at least rows*cols, where

layout=oneapi::mkl::layout::col_major

layout=oneapi::mkl::layout::row_major

rows (number of rows in C)

ldc

c_ncols

cols (number of columns in C)

c_nrows

ldc

c_nrows

Number of rows of matrix C.

c_ncols

Number of columns of matrix C.

ldc

Specifies the leading dimension of matrix C. Must be positive, and at least c_ncols if c_layout=oneapi::mkl::layout::row_major or at least c_nrows if c_layout=oneapi::mkl::layout::col_major.

dependencies

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

Output Parameters#

C

Overwritten by the updated matrix C.

Return Values (USM Only)#

sycl::event

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

Examples#

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

share/doc/mkl/examples/sycl/sparse_blas/source/csr_matmatd.cpp
share/doc/mkl/examples/sycl/sparse_blas/source/csr_matmatd_usm.cpp