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
and m-by-k matrix , k-by-columns matrix, and 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
and dense matrices. The possible options are described in layout enum class.- transpose_A
Specifies operation
op()on input matrix . The possible options are described in transpose enum class.- transpose_B
Specifies operation
op()on input matrix . The possible options are described in transpose enum class.- alpha
Specifies the scalar
.- A_handle
Handle to object containing sparse matrix,
. Created using the oneapi::mkl::sparse::set_csr_data routine.- B
The input dense matrix
in the sparse matrix-dense matrix product. is a one dimensional SYCL memory object containing an array of size:Bnot transposedBtransposedRow major
Bis ank-by-columnsmatrix so must have size at leastk*ldb.Bis ancolumns-by-kmatrix so must have size at leastcolumns*ldbColumn major
Bis ank-by-columnsmatrix so must have size at leastldb*columns.Bis ancolumns-by-kmatrix so must have size at leastldb*kSee Matrix Storage for more details.
- columns
Number of columns of matrix
.- ldb
Specifies the leading dimension of matrix
. It must be positive.Bnot transposedBtransposedRow major
ldbmust be at leastcolumns.ldbmust be at leastk.Column major
ldbmust be at leastk.ldbmust 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*ldcif row_major layout is used to store dense matrices or at leastldc*columnsif column_major layout is used to store dense matrices.- ldc
Specifies the leading dimension of matrix
. Must be positive and at leastcolumnsif row major layout is used to store dense matrices or at leastmif column major layout is used to store dense matrices.
Output Parameters
- C
Dense matrix output is overwritten by the updated matrix,
.
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
and dense matrices. The possible options are described in layout enum class.- transpose_A
Specifies operation
op()on input matrix . The possible options are described in transpose enum class.- transpose_B
Specifies operation
op()on input matrix . The possible options are described in transpose enum class.- alpha
Specifies the scalar
.- A_handle
Handle to object containing sparse matrix,
. 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:
Bnot transposedBtransposedRow major
Bis ank-by-columnsmatrix so must have size at leastk*ldb.Bis ancolumns-by-kmatrix so must have size at leastcolumns*ldbColumn major
Bis ank-by-columnsmatrix so must have size at leastldb*columns.Bis ancolumns-by-kmatrix so must have size at leastldb*kSee Matrix Storage for more details.
- columns
Number of columns of matrix
.- ldb
Specifies the leading dimension of matrix
. It must be positive.Bnot transposedBtransposedRow major
ldbmust be at leastcolumns.ldbmust be at leastk.Column major
ldbmust be at leastk.ldbmust 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*ldcif row_major layout is used to store dense matrices or at leastldc*columnsif column_major layout is used to store dense matrices.- ldc
Specifies the leading dimension of matrix
. Must be positive and at leastcolumnsif row major layout is used to store dense matrices or at leastmif 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
.
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