rocsparse_scsr2csc Interface Reference#
Convert a sparse CSR matrix into a sparse CSC matrix. More...
Public Member Functions | |
| integer(kind(rocsparse_status_success)) function | rocsparse_scsr2csc_ (handle, m, n, nnz, csr_val, csr_row_ptr, csr_col_ind, csc_val, csc_row_ind, csc_col_ptr, copy_values, idx_base, temp_buffer) |
| integer(kind(rocsparse_status_success)) function | rocsparse_scsr2csc_rank_0 (handle, m, n, nnz, csr_val, csr_row_ptr, csr_col_ind, csc_val, csc_row_ind, csc_col_ptr, copy_values, idx_base, temp_buffer) |
| integer(kind(rocsparse_status_success)) function | rocsparse_scsr2csc_rank_1 (handle, m, n, nnz, csr_val, csr_row_ptr, csr_col_ind, csc_val, csc_row_ind, csc_col_ptr, copy_values, idx_base, temp_buffer) |
Detailed Description
Convert a sparse CSR matrix into a sparse CSC matrix.
rocsparse_csr2csc converts a CSR matrix into a CSC matrix. The resulting matrix can also be seen as the transpose of the input matrix. rocsparse_csr2csc can also be used to convert a CSC matrix into a CSR matrix.
The conversion of a sparse matrix from CSR to CSC format involves two steps. First, call rocsparse_csr2csc_buffer_size to determine the size of the required tempory storage buffer. Then allocate this buffer. Secondly, call rocsparse_csr2csc to complete the conversion. After the conversion is complete, free the temporary buffer.
Both rocsparse_csr2csc_buffer_size and rocsparse_csr2csc take a rocsparse_action parameter as input. This copy_values parameter decides whether csc_row_ind and csc_val are filled during conversion (rocsparse_action_numeric) or whether only csc_row_ind is filled (rocsparse_action_symbolic). Using rocsparse_action_symbolic can be useful, for example, if only the sparsity pattern is required.
- Note
- This function is non-blocking and executed asynchronously with respect to the host. It can return before the actual computation has finished.
- This routine supports execution in a hipGraph context.
- Parameters
-
[in] handle - handle to the rocSPARSE library context queue. [in] m - number of rows of the sparse CSR matrix. [in] n - number of columns of the sparse CSR matrix. [in] nnz - number of non-zero entries of the sparse CSR matrix. [in] csr_val - array of nnzelements of the sparse CSR matrix.[in] csr_row_ptr - array of m+1elements that point to the start of every row of the sparse CSR matrix.[in] csr_col_ind - array of nnzelements containing the column indices of the sparse CSR matrix.[out] csc_val - array of nnzelements of the sparse CSC matrix.[out] csc_row_ind - array of nnzelements containing the row indices of the sparse CSC matrix.[out] csc_col_ptr - array of n+1elements that point to the start of every column of the sparse CSC matrix.[in] copy_values - rocsparse_action_symbolicorrocsparse_action_numeric.[in] idx_base - rocsparse_index_base_zeroorrocsparse_index_base_one.[in] temp_buffer - temporary storage buffer allocated by the user. The size is returned by rocsparse_csr2csc_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, ornnzis invalid.rocsparse_status_invalid_pointer csr_val,csr_row_ptr,csr_col_ind,csc_val,csc_row_ind,csc_col_ptr, ortemp_bufferpointer is invalid.rocsparse_status_arch_mismatch the device is not supported. rocsparse_status_internal_error an internal error occurred.
- Example
- This example computes the transpose of a CSR matrix. // 1 2 0 3 0// A = 0 4 5 0 0// 6 0 0 7 8rocsparse_int m_A = 3;rocsparse_int n_A = 5;rocsparse_int nnz_A = 8;csr_row_ptr_A[m_A + 1] = {0, 3, 5, 8}; // device memorycsr_col_ind_A[nnz_A] = {0, 1, 3, 1, 2, 0, 3, 4}; // device memorycsr_val_A[nnz_A] = {1, 2, 3, 4, 5, 6, 7, 8}; // device memory// Allocate memory for transposed CSR matrixrocsparse_int m_T = n_A;rocsparse_int n_T = m_A;rocsparse_int nnz_T = nnz_A;rocsparse_int* csr_row_ptr_T;rocsparse_int* csr_col_ind_T;float* csr_val_T;hipMalloc((void**)&csr_row_ptr_T, sizeof(rocsparse_int) * (m_T + 1));hipMalloc((void**)&csr_col_ind_T, sizeof(rocsparse_int) * nnz_T);hipMalloc((void**)&csr_val_T, sizeof(float) * nnz_T);// Obtain the temporary buffer sizesize_t buffer_size;rocsparse_csr2csc_buffer_size(handle,m_A,n_A,nnz_A,csr_row_ptr_A,csr_col_ind_A,&buffer_size);// Allocate temporary buffervoid* temp_buffer;hipMalloc(&temp_buffer, buffer_size);rocsparse_scsr2csc(handle,m_A,n_A,nnz_A,csr_val_A,csr_row_ptr_A,csr_col_ind_A,csr_val_T,csr_col_ind_T,csr_row_ptr_T,temp_buffer);@ rocsparse_index_base_zeroDefinition hipfort_rocsparse_enums.F90:42@ rocsparse_action_numericDefinition hipfort_rocsparse_enums.F90:75
- Example
- This example computes the symbolic transpose of A
Member Function/Subroutine Documentation
◆ rocsparse_scsr2csc_()
| integer(kind(rocsparse_status_success)) function hipfort_rocsparse::rocsparse_scsr2csc::rocsparse_scsr2csc_ | ( | type(c_ptr), value | handle, |
| integer(c_int), value | m, | ||
| integer(c_int), value | n, | ||
| integer(c_int), value | nnz, | ||
| type(c_ptr), value | csr_val, | ||
| type(c_ptr), value | csr_row_ptr, | ||
| type(c_ptr), value | csr_col_ind, | ||
| type(c_ptr), value | csc_val, | ||
| type(c_ptr), value | csc_row_ind, | ||
| type(c_ptr), value | csc_col_ptr, | ||
| integer(kind(rocsparse_action_symbolic)), value | copy_values, | ||
| integer(kind(rocsparse_index_base_zero)), value | idx_base, | ||
| type(c_ptr), value | temp_buffer | ||
| ) |
◆ rocsparse_scsr2csc_rank_0()
| integer(kind(rocsparse_status_success)) function hipfort_rocsparse::rocsparse_scsr2csc::rocsparse_scsr2csc_rank_0 | ( | type(c_ptr) | handle, |
| integer(c_int) | m, | ||
| integer(c_int) | n, | ||
| integer(c_int) | nnz, | ||
| real(c_float), target | csr_val, | ||
| integer(c_int), target | csr_row_ptr, | ||
| integer(c_int), target | csr_col_ind, | ||
| real(c_float), target | csc_val, | ||
| integer(c_int), target | csc_row_ind, | ||
| integer(c_int), target | csc_col_ptr, | ||
| integer(kind(rocsparse_action_symbolic)) | copy_values, | ||
| integer(kind(rocsparse_index_base_zero)) | idx_base, | ||
| type(c_ptr) | temp_buffer | ||
| ) |
◆ rocsparse_scsr2csc_rank_1()
| integer(kind(rocsparse_status_success)) function hipfort_rocsparse::rocsparse_scsr2csc::rocsparse_scsr2csc_rank_1 | ( | type(c_ptr) | handle, |
| integer(c_int) | m, | ||
| integer(c_int) | n, | ||
| integer(c_int) | nnz, | ||
| real(c_float), dimension(:), target | csr_val, | ||
| integer(c_int), dimension(:), target | csr_row_ptr, | ||
| integer(c_int), dimension(:), target | csr_col_ind, | ||
| real(c_float), dimension(:), target | csc_val, | ||
| integer(c_int), dimension(:), target | csc_row_ind, | ||
| integer(c_int), dimension(:), target | csc_col_ptr, | ||
| integer(kind(rocsparse_action_symbolic)) | copy_values, | ||
| integer(kind(rocsparse_index_base_zero)) | idx_base, | ||
| type(c_ptr) | temp_buffer | ||
| ) |
The documentation for this interface was generated from the following file: