rocsparse_sddmm Interface Reference

rocsparse_sddmm Interface Reference#

HIPFORT API Reference: hipfort_rocsparse::rocsparse_sddmm Interface Reference
hipfort_rocsparse::rocsparse_sddmm Interface Reference

Sampled Dense-Dense Matrix Multiplication. More...

Public Member Functions

integer(kind(rocsparse_status_success)) function rocsparse_sddmm_ (handle, opa, opb, alpha, mat_a, mat_b, beta, mat_c, compute_type, alg, temp_buffer)
 

Detailed Description

Sampled Dense-Dense Matrix Multiplication.

rocsparse_sddmm multiplies the scalar \(\alpha\) with the dense \(m \times k\) matrix \(op(A)\), the dense \(k \times n\) matrix \(op(B)\), filtered by the sparsity pattern of the \(m \times n\) sparse matrix \(C\) and adds the result to \(C\) scaled by \(\beta\). The final result is stored in the sparse \(m \times n\) matrix \(C\), such that

\[ C := \alpha ( op(A) \cdot op(B) ) \circ spy(C) + \beta C, \]

with

\[ op(A) = \left\{ \begin{array}{ll} A, & \text{if op(A) == rocsparse_operation_none} \\% A^T, & \text{if op(A) == rocsparse_operation_transpose} \\% \end{array} \right. \]

,

\[ op(B) = \left\{ \begin{array}{ll} B, & \text{if op(B) == rocsparse_operation_none} \\% B^T, & \text{if op(B) == rocsparse_operation_transpose} \\% \end{array} \right. \]

and

\[ spy(C)_{ij} = \left\{ \begin{array}{ll} 1, & \text{ if C_{ij} != 0} \\% 0, & \text{ otherwise} \\% \end{array} \right. \]

Computing the above sampled dense-dense multiplication requires three steps to complete. First, call rocsparse_sddmm_buffer_size to determine the size of the required temporary storage buffer. Next, allocate this buffer and call rocsparse_sddmm_preprocess, which performs any analysis of the input matrices that might be required. Finally, call rocsparse_sddmm to complete the computation. After all calls to rocsparse_sddmm are complete, the temporary buffer can be deallocated.

rocsparse_sddmm supports different algorithms which can provide better performance for different matrices.

Algorithms
Algorithms Deterministic Preprocessing Notes
rocsparse_sddmm_alg_default Yes No Uses the sparsity pattern of matrix C to perform a limited set of dot products.
rocsparse_sddmm_alg_dense Yes No Explicitly converts the matrix C into a dense matrix to perform a dense matrix multiply and add.

Currently, rocsparse_sddmm only supports the uniform precisions indicated in the table below. For the sparse matrix \(C\), rocsparse_sddmm supports the index types rocsparse_indextype_i32 and rocsparse_indextype_i64.

Uniform Precisions:
Uniform Precisions
A / B / C / compute_type
rocsparse_datatype_f16_r
rocsparse_datatype_f32_r
rocsparse_datatype_f64_r
rocsparse_datatype_f32_c
rocsparse_datatype_f64_c
Mixed Precisions:
Mixed Precisions
A / B C compute_type
rocsparse_datatype_f16_r rocsparse_datatype_f32_r rocsparse_datatype_f32_r
rocsparse_datatype_f16_r rocsparse_datatype_f16_r rocsparse_datatype_f32_r
rocsparse_datatype_bf16_r rocsparse_datatype_f32_r rocsparse_datatype_f32_r
rocsparse_datatype_bf16_r rocsparse_datatype_bf16_r rocsparse_datatype_f32_r
Note
The sparse matrix formats currently supported are: rocsparse_format_csr, rocsparse_format_csc, rocsparse_format_coo, rocsparse_format_coo_aos, and rocsparse_format_ell.
opA == rocsparse_operation_conjugate_transpose is not supported.
opB == rocsparse_operation_conjugate_transpose is not supported.
This routine supports execution in a hipGraph context only when alg == rocsparse_sddmm_alg_default.
This routine does not support batched computation.
Parameters
[in]handle- handle to the rocSPARSE library context queue.
[in]opA- dense matrix \(A\) operation type.
[in]opB- dense matrix \(B\) operation type.
[in]alpha- scalar \(\alpha\).
[in]mat_A- dense matrix \(A\) descriptor.
[in]mat_B- dense matrix \(B\) descriptor.
[in]beta- scalar \(\beta\).
[in,out]mat_C- sparse matrix \(C\) descriptor.
[in]compute_type- floating point precision for the SDDMM computation.
[in]alg- specification of the algorithm to use.
[in]temp_buffer- temporary storage buffer allocated by the user. The size must be greater or equal to the size obtained with rocsparse_sddmm_buffer_size.
Return values
rocsparse_status_successthe operation completed successfully.
rocsparse_status_invalid_valuethe value of opA, opB, compute_type, or alg is incorrect.
rocsparse_status_invalid_handlethe library context was not initialized.
rocsparse_status_invalid_pointeralpha and beta are invalid, or the mat_A, mat_B, mat_C, or temp_buffer pointer is invalid.
rocsparse_status_not_implementedopA == rocsparse_operation_conjugate_transpose or opB == rocsparse_operation_conjugate_transpose.
Example
This example performs a sampled dense-dense matrix product, \(C := \alpha ( A \cdot B ) \circ spy(C) + \beta C\) where \(\circ\) is the Hadamard product.

Member Function/Subroutine Documentation

◆ rocsparse_sddmm_()

integer(kind(rocsparse_status_success)) function hipfort_rocsparse::rocsparse_sddmm::rocsparse_sddmm_ ( type(c_ptr), value  handle,
integer(kind(rocsparse_operation_none)), value  opa,
integer(kind(rocsparse_operation_none)), value  opb,
type(c_ptr), value  alpha,
type(c_ptr), value  mat_a,
type(c_ptr), value  mat_b,
type(c_ptr), value  beta,
type(c_ptr), value  mat_c,
integer(kind(rocsparse_datatype_f16_r)), value  compute_type,
integer(kind(rocsparse_sddmm_alg_default)), value  alg,
type(c_ptr), value  temp_buffer 
)

The documentation for this interface was generated from the following file: