MPIAIJ and MatSetValuesBlocked
Satish Balay
balay at mcs.anl.gov
Mon May 4 13:45:04 CDT 2009
If you have a 3x3 block [i.e 9 values]. And compare MatSetValues() vs
MatSetValuesBlocked() - then the differences are:
1. 9 row,col indices provided for MatSetValues() vs 1-row,col index
for the block
2. The internal code for MatSetValues might have to loop over all 9
indices and do 9 searches/checks [for the correct location with the
matrix]. In the MatSetValuesBlocked() case - its just 1 search/check -
and all the 9 values copied into the internal structure..
3. there could potentiall be 9 function calls with MatSetValues() vs 1
for MatSetValuesBlocked()
Even if you have to format the data a bit [perhaps copy into array[9]]
that overhead might be less than the loop-search/insert overhead of
MatSetValues().
Satish
On Mon, 4 May 2009, Ryan Yan wrote:
> Hi Barry,
> My matrix is read from files stroing a matrix in the Block CRS format. So a
> natural way to create the matrix is MPIBAIJ. However, if I want to
> use MatSetValuesBlocked() for the newly created MPIBAIJ, I still need
> to load a tempary arrary(from Block CRS file) with the length of blocksize^2
> and pass it into the Matrix via MatSetValuesBlocked(). This process is
> similar to the MatSetValues. Could you make a little bit more clarification
> on why the MatSetValuesBlocked() have some advantage on blocked structure?
>
> Thanks,
>
> Yan
>
>
>
> On Fri, May 1, 2009 at 6:12 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
>
> >
> > Support for MatSetValuesBlocked() for AIJ matrices was added in PETSc
> > 3.0.0
> >
> > Note that if your matrix is truly blocked you should use BAIJ matrices, if
> > your matrix is not truly blocked then there is no benefit to using
> > MatSetValuesBlocked() it was added so people could easily switch between AIJ
> > and BAIJ for testing.
> >
> > Barry
> >
> >
> > On May 1, 2009, at 5:04 PM, Ryan Yan wrote:
> >
> > Hi, all,
> >> I am using MPIAIJ for my matrix A, but when I call the function
> >> MatSetValuesBlocked, I got the error:
> >>
> >> PetscPrintf(PETSC_COMM_WORLD, "breakpoint 1\n");
> >> ierr =
> >> MatSetValuesBlocked(A,1,&irow,1,(col_ind+icol),temp_vector,INSERT_VALUES);
> >> PetscPrintf(PETSC_COMM_WORLD, "breakpoint 2\n");
> >>
> >>
> >> breakpoint 1
> >> [0]PETSC ERROR: --------------------- Error Message
> >> ------------------------------------
> >> [0]PETSC ERROR: No support for this operation for this object type!
> >> [0]PETSC ERROR: Mat type mpiaij!
> >> [0]PETSC ERROR:
> >> ------------------------------------------------------------------------
> >> [0]PETSC ERROR: Petsc Release Version 2.3.3, Patch 15, Tue Sep 23 10:02:49
> >> CDT 2008 HG revision: 31306062cd1a6f6a2496fccb4878f485c9b91760
> >> [0]PETSC ERROR: See docs/changes/index.html for recent updates.
> >> [0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.
> >> [0]PETSC ERROR: See docs/index.html for manual pages.
> >> [0]PETSC ERROR:
> >> ------------------------------------------------------------------------
> >> [0]PETSC ERROR:
> >> /home/vyan2000/local/PPETSc/petsc-2.3.3-p15/src/ksp/ksp/examples/tutorials/ttt2/kspex1reader_binmpiaij
> >> on a linux-gnu named vyan2000-linux by vyan2000 Fri May 1 17:58:48 2009
> >> [0]PETSC ERROR: Libraries linked from
> >> /home/vyan2000/local/PPETSc/petsc-2.3.3-p15/lib/linux-gnu-c-debug
> >> [0]PETSC ERROR: Configure run at Thu Feb 5 21:10:10 2009
> >> [0]PETSC ERROR: Configure options --with-mpi-dir=/usr/lib/
> >> --with-debugger=gdb --with-shared=0 --download-hypre=1 --download-parmetis=1
> >> [0]PETSC ERROR:
> >> ------------------------------------------------------------------------
> >> [0]PETSC ERROR: MatSetValuesBlocked() line 1289 in
> >> src/mat/interface/matrix.c
> >> breakpoint 2
> >>
> >> Is it the reason that MatSetValuesBlocked only works for MPIBAIJ or
> >> SeqBAIJ?
> >>
> >> Thanks,
> >>
> >> Yan
> >>
> >
> >
>
More information about the petsc-users
mailing list