[petsc-users] Using MATAIJ and MATSBAIJ

Smith, Barry F. bsmith at mcs.anl.gov
Tue Jun 11 11:11:59 CDT 2019



> On Jun 11, 2019, at 10:29 AM, Zhang, Hong via petsc-users <petsc-users at mcs.anl.gov> wrote:
> 
> 
> Ian,
> I would suggest start using AIJ format.
> 
> I am Ian. I trying to implement a solver which involves a sparse symmetric matrix A multiplied by a dense matrix X. And because of the nature of the problem, the bandwidth of the matrix A would be kind of large.For A*X, I am thinking using reverse Cuthill-Mckee algorithm to reduce the bandwidth.
> 
> Are the following approach reasonable, or do you have a better advice?
> 
> 1. Use MatGetOrdering to get a MATORDERINGRCM ordering, and MatPermute to create a new with it.
> SBAIJ may not support some orderings. Matrix ordering for sbaij matrix is limited to symmetric ordering and requires restructuring the matrix. 
> 
> 2. What’s the difference by using MATAIJ and MATBAIJ in terms of the entry insertion

   If you can use MatSetValuesBlocked with BAIJ matrix then it is more efficient then calling it on AIJ.  MatMult() on a vector is more efficient with BAIJ or SBAIJ than AIJ. But we haven't provided optimized code for MatMatMult() for BAIJ. it could be written and might improve the performance a little. I would recommend starting with AIJ get your code working doing everything you want correctly. Then measure performance using -log_view and if these computations dominate trying switching to BAIJ and ask for help, if needed to fill in the missing pieces

  Barry



> and computation and MPI efficiency for a sparse-dense matrix multiplication? Would it be better to use MATSBAIJ in terms of the computational efficiency?
> SBAIJ stores upper triangular part of matrix, thus saves approximately half memory of a sparse matrix. However, it requires more data communications for y=A*x in general. in your case, C=A*X is a dense matrix, saving half of storage for sparse A may not be worth trading communication cost and functionalities. 
> 
> Hong



More information about the petsc-users mailing list