rocsparse_csrgemm_symbolic Interface Reference#
Sparse matrix sparse matrix symbolic multiplication using the CSR storage format. More...
Public Member Functions | |
| integer(kind(rocsparse_status_success)) function | rocsparse_csrgemm_symbolic_ (handle, trans_a, trans_b, m, n, k, descr_a, nnz_a, csr_row_ptr_a, csr_col_ind_a, descr_b, nnz_b, csr_row_ptr_b, csr_col_ind_b, descr_d, nnz_d, csr_row_ptr_d, csr_col_ind_d, descr_c, nnz_c, csr_row_ptr_c, csr_col_ind_c, info_c, temp_buffer) |
Detailed Description
Sparse matrix sparse matrix symbolic multiplication using the CSR storage format.
rocsparse_csrgemm_symbolic multiplies two sparsity patterns and adds an extra one:
\[ opA \cdot op(B) + D \]
with \(m \times k\) matrix \(A\), defined in CSR storage format, the sparse \(k \times n\) matrix \(B\), defined in CSR storage format, and the sparse \(m \times n\) matrix \(D\). The final result is stored in the sparse \(m \times n\) matrix \(C\), defined in CSR storage format, such that
\[ C := op(A) \cdot op(B) + D, \]
with
\[ op(A) = \left\{ \begin{array}{ll} A, & \text{if trans_A == rocsparse_operation_none} \\% A^T, & \text{if trans_A == rocsparse_operation_transpose} \\% A^H, & \text{if trans_A == rocsparse_operation_conjugate_transpose} \end{array} \right. \]
and
\[ op(B) = \left\{ \begin{array}{ll} B, & \text{if trans_B == rocsparse_operation_none} \\% B^T, & \text{if trans_B == rocsparse_operation_transpose} \\% B^H, & \text{if trans_B == rocsparse_operation_conjugate_transpose} \end{array} \right. \]
It is assumed that csr_row_ptr_C has already been filled and that csr_col_ind_C is allocated by the user. csr_row_ptr_C and the allocation size of csr_col_ind_C are defined by the number of non-zero elements of the sparse CSR matrix C. Both can be obtained by using rocsparse_csrgemm_nnz(). The required buffer size for the computation can be obtained by rocsparse_scsrgemm_buffer_size(), rocsparse_dcsrgemm_buffer_size(), rocsparse_ccsrgemm_buffer_size(), and rocsparse_zcsrgemm_buffer_size(), respectively.
- Note
- Currently, only
trans_A==rocsparse_operation_noneis supported. -
Currently, only
trans_B==rocsparse_operation_noneis supported. -
Currently, only
rocsparse_matrix_type_generalis supported. - Note that for matrix products with more than 4096 non-zero entries per row, an additional temporary storage buffer is allocated by the algorithm.
- This function is blocking with respect to the host.
- This routine does not support execution in a hipGraph context.
- Parameters
-
[in] handle - handle to the rocSPARSE library context queue. [in] trans_A - matrix \(A\) operation type. [in] trans_B - matrix \(B\) operation type. [in] m - number of rows of the sparse CSR matrix \(op(A)\) and \(C\). [in] n - number of columns of the sparse CSR matrix \(op(B)\) and \(C\). [in] k - number of columns of the sparse CSR matrix \(op(A)\) and number of rows of the sparse CSR matrix \(op(B)\). [in] descr_A - descriptor of the sparse CSR matrix \(A\). Currently, only rocsparse_matrix_type_generalis supported.[in] nnz_A - number of non-zero entries of the sparse CSR matrix \(A\). [in] csr_row_ptr_A - array of m+1elements ( \(op(A) == A\),k+1otherwise) that point to the start of every row of the sparse CSR matrix \(op(A)\).[in] csr_col_ind_A - array of nnz_Aelements containing the column indices of the sparse CSR matrix \(A\).[in] descr_B - descriptor of the sparse CSR matrix \(B\). Currently, only rocsparse_matrix_type_generalis supported.[in] nnz_B - number of non-zero entries of the sparse CSR matrix \(B\). [in] csr_row_ptr_B - array of k+1elements ( \(op(B) == B\),m+1otherwise) that point to the start of every row of the sparse CSR matrix \(op(B)\).[in] csr_col_ind_B - array of nnz_Belements containing the column indices of the sparse CSR matrix \(B\).[in] descr_D - descriptor of the sparse CSR matrix \(D\). Currently, only rocsparse_matrix_type_generalis supported.[in] nnz_D - number of non-zero entries of the sparse CSR matrix \(D\). [in] csr_row_ptr_D - array of m+1elements that point to the start of every row of the sparse CSR matrix \(D\).[in] csr_col_ind_D - array of nnz_Delements containing the column indices of the sparse CSR matrix \(D\).[in] descr_C - descriptor of the sparse CSR matrix \(C\). Currently, only rocsparse_matrix_type_generalis supported.[in] nnz_C - number of non-zero entries of the sparse CSR matrix \(C\). [in] csr_row_ptr_C - array of m+1elements that point to the start of every row of the sparse CSR matrix \(C\).[out] csr_col_ind_C - array of nnz_Celements containing the column indices of the sparse CSR matrix \(C\).[in] info_C - structure that holds metadata for the sparse CSR matrix \(C\). [in] temp_buffer - temporary storage buffer allocated by the user. The size is returned by rocsparse_scsrgemm_buffer_size(), rocsparse_dcsrgemm_buffer_size(), rocsparse_ccsrgemm_buffer_size(), or rocsparse_zcsrgemm_buffer_size().
- Return values
-
rocsparse_status_success the operation completed successfully. rocsparse_status_invalid_handle the library context was not initialized. rocsparse_status_invalid_size m,n,k,nnz_A,nnz_B, ornnz_Dis invalid.rocsparse_status_invalid_pointer descr_A,csr_row_ptr_A,csr_col_ind_A,descr_B,csr_row_ptr_B,csr_col_ind_B,descr_D,csr_row_ptr_D,csr_col_ind_Dcsr_row_ptr_C,csr_col_ind_C,info_C, ortemp_bufferis invalid.rocsparse_status_memory_error additional buffer for long rows could not be allocated. rocsparse_status_not_implemented trans_A!=rocsparse_operation_none,trans_B!=rocsparse_operation_none, orrocsparse_matrix_type!=rocsparse_matrix_type_general.
- Example
- This example multiplies symbolically two CSR matrices and adds the result to another CSR matrix. // Initialize scalar multipliersfloat alpha = 2.0f;float beta = 1.0f;// Create matrix descriptorsrocsparse_mat_descr descr_A;rocsparse_mat_descr descr_B;rocsparse_mat_descr descr_C;rocsparse_mat_descr descr_D;rocsparse_create_mat_descr(&descr_A);rocsparse_create_mat_descr(&descr_B);rocsparse_create_mat_descr(&descr_C);rocsparse_create_mat_descr(&descr_D);// Create matrix info structurerocsparse_mat_info info_C;rocsparse_create_mat_info(&info_C);// Set pointer mode// Query rocsparse for the required buffer sizesize_t buffer_size;rocsparse_scsrgemm_buffer_size(handle,m,n,k,&alpha,descr_A,nnz_A,csr_row_ptr_A,csr_col_ind_A,descr_B,nnz_B,csr_row_ptr_B,csr_col_ind_B,&beta,descr_D,nnz_D,csr_row_ptr_D,csr_col_ind_D,info_C,&buffer_size);// Allocate buffervoid* buffer;hipMalloc(&buffer, buffer_size);// Obtain number of total non-zero entries in C and row pointers of Crocsparse_int nnz_C;hipMalloc((void**)&csr_row_ptr_C, sizeof(rocsparse_int) * (m + 1));rocsparse_csrgemm_nnz(handle,m,n,k,descr_A,nnz_A,csr_row_ptr_A,csr_col_ind_A,descr_B,nnz_B,csr_row_ptr_B,csr_col_ind_B,descr_D,nnz_D,csr_row_ptr_D,csr_col_ind_D,descr_C,csr_row_ptr_C,&nnz_C,info_C,buffer);// Compute column indices of ChipMalloc((void**)&csr_col_ind_C, sizeof(rocsparse_int) * nnz_C);rocsparse_csrgemm_symbolic(handle,m,n,k,descr_A,nnz_A,csr_row_ptr_A,csr_col_ind_A,descr_B,nnz_B,csr_row_ptr_B,csr_col_ind_B,descr_D,nnz_D,csr_row_ptr_D,csr_col_ind_D,descr_C,nnz_C,csr_row_ptr_C,csr_col_ind_C,info_C,buffer);Create a matrix descriptor.Definition hipfort_rocsparse.F90:436Create a matrix info structure.Definition hipfort_rocsparse.F90:795Sparse matrix sparse matrix multiplication using the CSR storage format.Definition hipfort_rocsparse.F90:13233Sparse matrix sparse matrix symbolic multiplication using the CSR storage format.Definition hipfort_rocsparse.F90:13968Definition hipfort_rocsparse.F90:12963Specify the pointer mode.Definition hipfort_rocsparse.F90:320@ rocsparse_operation_noneDefinition hipfort_rocsparse_enums.F90:35@ rocsparse_pointer_mode_hostDefinition hipfort_rocsparse_enums.F90:104
Member Function/Subroutine Documentation
◆ rocsparse_csrgemm_symbolic_()
| integer(kind(rocsparse_status_success)) function hipfort_rocsparse::rocsparse_csrgemm_symbolic::rocsparse_csrgemm_symbolic_ | ( | type(c_ptr), value | handle, |
| integer(kind(rocsparse_operation_none)), value | trans_a, | ||
| integer(kind(rocsparse_operation_none)), value | trans_b, | ||
| integer(c_int), value | m, | ||
| integer(c_int), value | n, | ||
| integer(c_int), value | k, | ||
| type(c_ptr), value | descr_a, | ||
| integer(c_int), value | nnz_a, | ||
| type(c_ptr), value | csr_row_ptr_a, | ||
| type(c_ptr), value | csr_col_ind_a, | ||
| type(c_ptr), value | descr_b, | ||
| integer(c_int), value | nnz_b, | ||
| type(c_ptr), value | csr_row_ptr_b, | ||
| type(c_ptr), value | csr_col_ind_b, | ||
| type(c_ptr), value | descr_d, | ||
| integer(c_int), value | nnz_d, | ||
| type(c_ptr), value | csr_row_ptr_d, | ||
| type(c_ptr), value | csr_col_ind_d, | ||
| type(c_ptr), value | descr_c, | ||
| integer(c_int), value | nnz_c, | ||
| type(c_ptr), value | csr_row_ptr_c, | ||
| type(c_ptr), value | csr_col_ind_c, | ||
| type(c_ptr), value | info_c, | ||
| type(c_ptr), value | temp_buffer | ||
| ) |
The documentation for this interface was generated from the following file: