oneapi::mkl::sparse::gemm
Computes a sparse matrix-dense matrix product.
Description
Refer to Supported Types for a list of supported
<fp>
and <intType>
and refer
to Exceptions for a detailed description of the exceptions thrown. The
oneapi::mkl::sparse::gemm
routine computes a sparse matrix-dense matrix product defined as
where:
and
are scalars,
is a sparse matrix of size
is a matrix modifier for



num_rows
rows by num_cols
columns, 
A
and B
using the following description:
The dense matrix objects
B
and C
are stored with row-major or column-major layout and have appropriately sized number of rows for the matrix product and columns
number of columns.API
Syntax
Currently, complex types are not supported.
Using SYCL buffers:
namespace oneapi::mkl::sparse {
void gemm(cl::sycl::queue &queue,
oneapi::mkl::layout dense_matrix_layout,
oneapi::mkl::transpose transpose_A,
oneapi::mkl::transpose transpose_B,
const fp alpha,
matrix_handle_t handle,
cl::sycl::buffer<fp, 1> &b,
const std::int64_t columns,
const std::int64_t ldb,
const fp beta,
cl::sycl::buffer<fp, 1> &c,
const std::int64_t ldc);
}
namespace oneapi::mkl::sparse {
[[deprecated("Use oneapi::mkl::sparse::gemm(queue, oneapi::mkl::layout::row_major, transpose_A, oneapi::mkl::transpose:nontrans, alpha, ... ) instead.")]]
void gemm (
cl::sycl::queue &queue,
oneapi::mkl::transpose transpose_flag,
const fp alpha,
oneapi::mkl::sparse::matrix_handle_t handle,
cl::sycl::buffer<fp, 1> &b,
const std::int64_t columns,
const std::int64_t ldb,
const fp beta,
cl::sycl::buffer<fp, 1> &c,
const std::int64_t ldc)
}
Using USM pointers:
namespace oneapi::mkl::sparse {
cl::sycl::event gemm(
cl::sycl::queue &queue,
oneapi::mkl::layout dense_matrix_layout,
oneapi::mkl::transpose transpose_A,
oneapi::mkl::transpose transpose_B,
const fp alpha,
matrix_handle_t handle,
fp *b,
const std::int64_t columns,
const std::int64_t ldb,
const fp beta,
fp *c,
const std::int64_t ldc,
const std::vector<cl::sycl::event> &dependencies = {});
}
namespace oneapi::mkl::sparse {
[[deprecated("Use oneapi::mkl::sparse::gemm(queue, oneapi::mkl::layout::row_major, transpose_A, oneapi::mkl::transpose:nontrans, alpha, ... ) instead.")]]
cl::sycl::event gemm (
cl::sycl::queue &queue,
oneapi::mkl::transpose transpose_flag,
const fp alpha,
oneapi::mkl::sparse::matrix_handle_t handle,
const fp *b,
const std::int64_t columns,
const std::int64_t ldb,
const fp beta,
fp *c,
const std::int64_t ldc,
const std::vector<cl::sycl::event> &dependencies = {})
}
Include Files
- oneapi/mkl/spblas.hpp
Input Parameters
- queue
- Specifies the SYCL command queue which will be used for SYCL kernels execution.
- dense_matrix_layout
- Specifies the storage scheme in memory for the dense matrices. Note that this layout applies to bothBandCdense matrices.
- transpose_A (in old API, transpose_flag)
- Specifies operationop()on input matrixA.oneapi::mkl::transpose::nontransNon-transpose,
.
oneapi::mkl::transpose::transTranspose,.
oneapi::mkl::transpose::conjtransConjugate transpose,.
Currently, the only supported case for operation isoneapi::mkl::transpose::nontrans. - transpose_B
- Specifies operationop()on input matrixB.oneapi::mkl::transpose::nontransNon-transpose,
.
oneapi::mkl::transpose::transTranspose,.
oneapi::mkl::transpose::conjtransConjugate transpose,.
Currently, the only supported case for operation isoneapi::mkl::transpose::nontrans. - alpha
- Specifies the scalar,
.
- handle
- Handle to object containing sparse matrix and other internal data. Created using one of theoneapi::mkl::sparse::set_<sparse_matrix_type>_dataroutines.Currently, the only supported case for <sparse_matrix_type> is csr.
- b
- SYCL buffer or device-accessible USM pointer of size at leastrows*cols, where (with the assumption oftranspose_B == oneapi::mkl::transpose::nontrans).layout=oneapi::mkl::layout::col-majorlayout=oneapi::mkl::layout::row-majorrows (number of rows inB)ldbif
, number of columns in
Aif, number of rows in
Acols (number of columns inB)columnsldb - columns
- Number of columns of matrixC.
- ldb
- Specifies the leading dimension of matrixB. Must be positive, and at leastcolumnsifdense_matrix_layout=oneapi::mkl::layout::row-majoror at least number of columns inAifdense_matrix_layout=oneapi::mkl::layout::col-major.
- beta
- Specifies the scalar,
.
- c
- SYCL buffer or device-accessible USM pointer of size at leastrows*cols, where:layout=oneapi::mkl::layout::col-majorlayout=oneapi::mkl::layout::row-majorrows (number of rows inC)ldcif
, number of rows in
Aif, number of columns in
Acols (number of columns inC)columnsldc - ldc
- Specifies the leading dimension of matrixC. Must be positive, and at leastcolumnsifdense_matrix_layout=oneapi::mkl::layout::row-majoror at least number of rows inAifdense_matrix_layout=oneapi::mkl::layout::col-major.
- dependencies
- A vector of typestd::vector<cl::sycl::event>containing the list of events that theoneapi::mkl::sparse::gemmroutine depends on.
Output Parameters
- c
- Overwritten by the updated matrixC.
Return Values (USM Only)
- cl::sycl::event
- SYCL event which can be waited upon or added as a dependency for the completion of thegemmroutine.
Examples
An example of how to use
oneapi::mkl::sparse::gemm
with SYCL
buffers or USM can be found in the oneMKL installation
directory, under:examples/dpcpp/sparse_blas/source/sparse_gemm_row_major.cpp
examples/dpcpp/sparse_blas/source/sparse_gemm_row_major_usm.cpp
examples/dpcpp/sparse_blas/source/sparse_gemm_col_major.cpp
examples/dpcpp/sparse_blas/source/sparse_gemm_col_major_usm.cpp