gemm#
Computes a sparse matrix times dense matrix product.
Description and Assumptions
Refer to Supported Types for a list of supported <fp>
and <intType>
types. The oneapi::mkl::sparse::gemm routine computes a sparse matrix-dense
matrix product defined as
where \(\alpha\) and \(\beta\) are scalars, \(A\) is a sparse matrix, \(B\) and \(C\) are dense matrices, \(\text{op}()\) is a matrix modifier for \(A\) and \(B\) using the following description:
and \(\text{op}(A)\) is an m
-by-k
matrix , \(\text{op}(B)\) is an k
-by-columns
matrix, and \(C\) is an m
-by-columns
matrix.
Dense matrix storage is in either row-major or column-major format. Sparse matrix formats are compressed sparse row (CSR) formats.
gemm (Buffer version)#
Syntax
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 fp alpha,
oneapi::mkl::sparse::matrix_handle_t A_handle,
sycl::buffer<fp, 1> &B,
const std::int64_t columns,
const std::int64_t ldb,
const fp beta,
sycl::buffer<fp, 1> &C,
const std::int64_t ldc);
}
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. The possible options are described in layout enum class.
- transpose_A
Specifies operation
op()
on input matrix \(A\). The possible options are described in transpose enum class.- transpose_B
Specifies operation
op()
on input matrix \(B\). The possible options are described in transpose enum class.- alpha
Specifies the scalar \(\alpha\).
- A_handle
Handle to object containing sparse matrix, \(A\). Created using the oneapi::mkl::sparse::set_csr_data routine.
- B
The input dense matrix \(B\) in the sparse matrix-dense matrix product. \(B\) is a one dimensional SYCL memory object containing an array of size:
B
not transposedB
transposedRow major
B
is ank
-by-columns
matrix so must have size at leastk
*ldb
.B
is ancolumns
-by-k
matrix so must have size at leastcolumns
*ldb
Column major
B
is ank
-by-columns
matrix so must have size at leastldb
*columns
.B
is ancolumns
-by-k
matrix so must have size at leastldb
*k
See Matrix Storage for more details.
- columns
Number of columns of matrix \(C\).
- ldb
Specifies the leading dimension of matrix \(B\). It must be positive.
B
not transposedB
transposedRow major
ldb
must be at leastcolumns
.ldb
must be at leastk
.Column major
ldb
must be at leastk
.ldb
must be at leastcolumns
.- beta
Specifies the scalar
beta
.- C
The dense matrix input/output array. A one-dimensional SYCL memory object containing an array of size at least
m
*ldc
if row_major layout is used to store dense matrices or at leastldc
*columns
if column_major layout is used to store dense matrices.- ldc
Specifies the leading dimension of matrix \(C\). Must be positive and at least
columns
if row major layout is used to store dense matrices or at leastm
if column major layout is used to store dense matrices.
Output Parameters
- C
Dense matrix output is overwritten by the updated matrix, \(C\).
Throws
This routine shall throw the following exceptions if the associated condition is detected. An implementation may throw additional implementation-specific exception(s) in case of error conditions not covered here.
gemm (USM version)#
Syntax
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 fp alpha,
oneapi::mkl::sparse::matrix_handle_t A_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<sycl::event> &dependencies = {});
}
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. The possible options are described in layout enum class.
- transpose_A
Specifies operation
op()
on input matrix \(A\). The possible options are described in transpose enum class.- transpose_B
Specifies operation
op()
on input matrix \(B\). The possible options are described in transpose enum class.- alpha
Specifies the scalar \(\alpha\).
- A_handle
Handle to object containing sparse matrix, \(A\). Created using the oneapi::mkl::sparse::set_csr_data routine.
- B
The dense matrix in the sparse-dense matrix product. A device accessible USM object containing an array of size:
B
not transposedB
transposedRow major
B
is ank
-by-columns
matrix so must have size at leastk
*ldb
.B
is ancolumns
-by-k
matrix so must have size at leastcolumns
*ldb
Column major
B
is ank
-by-columns
matrix so must have size at leastldb
*columns
.B
is ancolumns
-by-k
matrix so must have size at leastldb
*k
See Matrix Storage for more details.
- columns
Number of columns of matrix \(C\).
- ldb
Specifies the leading dimension of matrix \(B\). It must be positive.
B
not transposedB
transposedRow major
ldb
must be at leastcolumns
.ldb
must be at leastk
.Column major
ldb
must be at leastk
.ldb
must be at leastcolumns
.- beta
Specifies the scalar
beta
.- C
The dense matrix input/output array. A device accessible USM object containing an array of size at least
m
*ldc
if row_major layout is used to store dense matrices or at leastldc
*columns
if column_major layout is used to store dense matrices.- ldc
Specifies the leading dimension of matrix \(C\). Must be positive and at least
columns
if row major layout is used to store dense matrices or at leastm
if column major layout is used to store dense matrices.- dependencies
List of events that oneapi::mkl::sparse::gemm routine depends on. If omitted, defaults to no dependencies.
Output Parameters
- C
Dense matrix output is overwritten by the updated matrix \(C\).
Throws
This routine shall throw the following exceptions if the associated condition is detected. An implementation may throw additional implementation-specific exception(s) in case of error conditions not covered here.
Return Values
Output event that can be waited upon or added as a dependency for the completion of gemm routine.
Parent topic: Sparse BLAS