A newer version of this document is available. Customers should click here to go to the newest version.
oneapi::mkl::sparse::gemm
Computes a sparse matrix-dense matrix product.
Description
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 num_rows rows by num_cols columns, and
is a matrix modifier for 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 an appropriate number of rows for the matrix product and columns number of columns.
API
Syntax
Using SYCL buffers:
namespace oneapi::mkl::sparse {
void gemm(sycl::queue &queue,
oneapi::mkl::layout dense_matrix_layout,
oneapi::mkl::transpose transpose_A,
oneapi::mkl::transpose transpose_B,
const DATA_TYPE alpha,
matrix_handle_t handle,
sycl::buffer<DATA_TYPE, 1> &b,
const std::int64_t columns,
const std::int64_t ldb,
const DATA_TYPE beta,
sycl::buffer<DATA_TYPE, 1> &c,
const std::int64_t ldc);
}
Using USM pointers:
namespace oneapi::mkl::sparse {
sycl::event gemm(
sycl::queue &queue,
oneapi::mkl::layout dense_matrix_layout,
oneapi::mkl::transpose transpose_A,
oneapi::mkl::transpose transpose_B,
const DATA_TYPE alpha,
matrix_handle_t handle,
DATA_TYPE *b,
const std::int64_t columns,
const std::int64_t ldb,
const DATA_TYPE beta,
DATA_TYPE *c,
const std::int64_t ldc,
const std::vector<sycl::event> &dependencies = {});
}
int main() {
...
// For using SYCL buffers
oneapi::mkl::sparse::gemm(queue, oneapi::mkl::layout::row_major, transpose_A, oneapi::mkl::transpose:nontrans, alpha, handle, b, ... );
or
// For using USM pointers
auto ev_gemm = oneapi::mkl::sparse::gemm(queue, oneapi::mkl::layout::row_major, transpose_A, oneapi::mkl::transpose:nontrans, alpha, handle, b, ... );
...
}
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 both B and C dense matrices.
- transpose_A (in old API, transpose_flag)
-
Specifies operation op() on input matrix A.
oneapi::mkl::transpose::nontrans
Non-transpose,
.oneapi::mkl::transpose::trans
Transpose,
.oneapi::mkl::transpose::conjtrans
Conjugate transpose,
. - transpose_B
-
Specifies operation op() on input matrix B.
oneapi::mkl::transpose::nontrans
Non-transpose,
.oneapi::mkl::transpose::trans
Transpose,
.oneapi::mkl::transpose::conjtrans
Conjugate transpose,
.NOTE:Currently, the only supported case for operation is oneapi::mkl::transpose::nontrans. - alpha
-
Specifies the scalar,
. - handle
-
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:Currently, the only supported case for <sparse_matrix_type> is csr. - b
-
SYCL buffer or device-accessible USM pointer of size at least rows*cols, where (with the assumption of transpose_B == oneapi::mkl::transpose::nontrans).
layout=oneapi::mkl::layout::col-major
layout=oneapi::mkl::layout::row-major
rows (number of rows in B)
ldb
if
, number of columns in Aif
, number of rows in Acols (number of columns in B)
columns
ldb
- columns
-
Number of columns of matrix C.
- ldb
-
Specifies the leading dimension of matrix B. Must be positive, and at least columns if dense_matrix_layout=oneapi::mkl::layout::row-major or at least number of columns in A if dense_matrix_layout=oneapi::mkl::layout::col-major.
- beta
-
Specifies the scalar,
. - 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
if
, number of rows in Aif
, number of columns in Acols (number of columns in C)
columns
ldc
- ldc
-
Specifies the leading dimension of matrix C. Must be positive, and at least columns if dense_matrix_layout=oneapi::mkl::layout::row-major or at least number of rows in A if dense_matrix_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::gemm routine depends on.
Output Parameters
- c
-
Overwritten by the updated matrix C.
Return Values (USM Only)
- sycl::event
-
SYCL event which can be waited upon or added as a dependency for the completion of the gemm routine.
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:
share/doc/mkl/examples/sycl/sparse_blas/source/sparse_gemm_row_major.cpp
share/doc/mkl/examples/sycl/sparse_blas/source/sparse_gemm_row_major_usm.cpp
share/doc/mkl/examples/sycl/sparse_blas/source/sparse_gemm_col_major.cpp
share/doc/mkl/examples/sycl/sparse_blas/source/sparse_gemm_col_major_usm.cpp