Xiangdong: MatCreateMPIBAIJWithArrays() is obviously buggy, and not been tested.
> 1) In the remark of the function MatCreateMPIBAIJWithArrays, it says " bs - > the block size, only a block size of 1 is supported". Why must the block > size be 1? Is this a typo? > > http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/ > Mat/MatCreateMPIBAIJWithArrays.html > It seems only bs=1 was implemented. I would not trust it without a test example. > > 2) In the Line 4040 of the implemention of MatCreateMPIBAIJWithArrays, > would the matrix type be matmpibaij instead of matmpiSbaij? > This is an error. It should be matmpibaij. > > http://www.mcs.anl.gov/petsc/petsc-current/src/mat/impls/bai > j/mpi/mpibaij.c.html#MatCreateMPIBAIJWithArrays > > 4031: PetscErrorCode MatCreateMPIBAIJWithArrays(MPI_Comm comm,PetscInt > bs,PetscInt m,PetscInt n,PetscInt M,PetscInt N,const PetscInt i[],const > PetscInt j[],const PetscScalar a[],Mat *mat) > 4032: { > > 4036: if (i[0]) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"i > (row indices) must start with 0"); > 4037: if (m < 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"local > number of rows (m) cannot be PETSC_DECIDE, or negative"); > 4038: MatCreate(comm,mat); > 4039: MatSetSizes(*mat,m,n,M,N); > 4040: MatSetType(*mat,MATMPISBAIJ); > It should be MATMPIBAIJ. > > 3) I want to create a petsc matrix M equivalent to the sum of two block > csr matrix/array (M1csr, M2csr). What is the best way to achieve it? I am > thinking of created two petsc baij matrix (M1baij and M2baij) by > calling MatCreateMPIBAIJWithArrays twice and then call MATAXPY to get the > sum M=M1baij + M2baij. Is there a better way to do it? > This is an approach. However MatCreateMPIBAIJWithArrays() needs to be fixed, tested and implemented with requested bs. What bs do you need? Why not use MatCreate(), MatSetValuses() (set a block values at time) to create two MPIBAIJ matrices, then call MATAXPY. Since petsc MPIBAIJ matrix has different internal data structure than csr, "The i, j, and a arrays ARE copied by MatCreateMPIBAIJWithArrays() into the internal format used by PETSc;", so this approach would give similar performance. Hong
