Two-stage Algorithm in Inspector-Executor Sparse BLAS Routines
- The first stage allocates data which is necessary for the memory estimation (arraysrows_start/rows_endorcols_start/cols_enddepending on the format, (see Sparse Matrix Storage Formats) and computes the number of entries or the full structure of the matrix.The format of the output is decided internally but can be checked using the export functionalitymkl_sparse_?_export_<format>.
- The second stage allocates data and computes column or row indices (depending on the format) of non-zero elements and/or values of the output matrix.
Allocates and computes only the
rows_end(CSR/BSR format) or
cols_end(CSC format) arrays for the output matrix. After this stage, by calling
mkl_sparse_?_export_<format>, you can obtain the number of non-zeros in the output matrix and calculate the amount of memory required for the output matrix.
Allocates and computes row/column indices provided that
cols_endhave already been computed in a prior call with the request
SPARSE_STAGE_NNZ_COUNT. The values of the output matrix are not computed.
Depending on the state of the output matrix
Con entry to the routine, this stage does one of the following:
Allocates and computes the output matrix structure in a single step. The values of the output matrix are not computed.
Allocates and computes the entire output matrix (structure and values) in a single step.
sparse_matrix_t csrC = NULL; status = mkl_sparse_sp2m (opA, descrA, csrA, opB, descrB, csrB, SPARSE_STAGE_NNZ_COUNT, &csrC); /* optional calculation of nnz in the output matrix for getting a memory estimate */ status = mkl_sparse_?_export_csr (csrC, &indexing, &nrows, &ncols, &rows_start, &rows_end, &col_indx, &values); MKL_INT nnz = rows_end[nrows-1] - rows_start;
status = mkl_sparse_sp2m (opA, descrA, csrA, opB, descrB, csrB, SPARSE_STAGE_FINALIZE_MULT, &csrC);
status = mkl_sparse_sp2m (opA, descrA, csrA, opB, descrB, csrB, SPARSE_STAGE_FULL_MULT, &csrC);