Jed Brown jed at
Thu Dec 3 05:48:39 CST 2009

On Thu, 03 Dec 2009 11:40:14 +0100, jarunan at wrote:
> Could I use BAIJ format if my block size is not the same in each
> block?

No, but AIJ uses Inodes when you have adjacent rows with the same
nonzero pattern, this gives some advantages of BAIJ in sparse matrix
kernels (MatMult, MatSolve, MatRelax).

> At the end of the day, would these 2 structures of matrix affect  
> differently in solving performance such as speed up?

This is very dependent on the preconditioner.  BAIJ reduces memory usage
from 12 bytes per nonzero to about 8 (assuming scalar=double, 32-bit
indices), and makes memory access slightly more regular.  Despite AIJ
using Inodes, I frequently see BAIJ being faster by this ratio (8/12).
BAIJ can reduce setup time (factorization) by a larger factor.

Sometimes it is worth storing a small number of explicit zeros in order
to have constant block size.  Note that many third-party preconditioners
can not use BAIJ, but if you insert values with MatSetValuesBlock, you
can still always run with -mat_type aij.


More information about the petsc-users mailing list