MatGetSubMatrix() and MatGetSubMatrices()

Barry Smith bsmith at mcs.anl.gov
Tue Mar 4 13:48:21 CST 2008


On Mar 4, 2008, at 11:22 AM, Yujie wrote:

> Dear Barry:
>
> That is, if one wants to generate different sub-matrices at  
> different nodes of the cluster from the same matrix, only  
> MatGetSubMatrices() is available?

    Yes
>
>
> If I use MatDistribute_MPIAIJ to convert a sequential matrix to  
> parallel one, how to control which nodes of the cluster the  
> submatrix of the parallel matrix is distributed into? For example,  
> in a cluster, there are 10 nodes, I only want to use the specified 5  
> nodes for
> distributing the matrix. thanks a lot.

    That is the comm argument to the function. In PETSc all objects  
are laid out on an MPI_Comm, thus
using subsets of nodes for various objects is very easy, just create  
the appropriate MPI_Comm and use
it to create the object.

    Barry

>
>
> Regards,
> Yujie
>
>
> On 3/4/08, Barry Smith <bsmith at mcs.anl.gov> wrote:
>
> On Mar 4, 2008, at 1:47 AM, Yujie wrote:
>
> > Hi, everyone
> >
> > #include "petscmat.h"
> > PetscErrorCode PETSCMAT_DLLEXPORT MatGetSubMatrix(Mat mat,IS
> > isrow,IS iscol,PetscInt csize,MatReuse cll,Mat *newmat)
> > #include "petscmat.h"
> > PetscErrorCode PETSCMAT_DLLEXPORT MatGetSubMatrices(Mat mat,PetscInt
> > n,const IS irow[],const IS icol[],MatReuse scall,Mat *submat[])
> >
> > To my knowledge, I can't get different matrices at different nodes
> > by setting different isrows and iscol with MatGetSubMatrix().
> > Because isrow  is rows current processor should obtain and the iscol
> > argument must be the same on each processor.
> > Furthermore, I can't get different parallel matrices at different
> > nodes by setting different irow[] and icolp[] with
> > MatGetSubMatrices() assuming I only want to get a matrix at each  
> node.
> > Because this function only gets different sequential matrices at
> > different nodes. Is it right?
> >
>
>     MatGetSubMatrices() gets one or more sequential matrix on each
> process.
>     MatGetSubMatrix() gets ONE parallel matrix that lives on the same
> communicator has the original matrix
>
>
> > Another equestion is how to partition the matrix when calling
> > MatConvert() to convert a sequential matrix to a parallel one?
>
>
>     MatConvert() is not for converting sequential matrix to parallel;
> the communicator of a the new matrix from MatConvert()
> is always the same as the old one.
>
>     In petsc-dev there is a utility for AIJ matrices that takes a
> given sequential AIJ matrix and makes it parallel, called
>
> /*
>      Distributes a SeqAIJ matrix across a set of processes. Code
> stolen from
>      MatLoad_MPIAIJ(). Horrible lack of reuse. Should be a routine for
> each matrix type.
>
>      Only for square matrices
> */
> PetscErrorCode MatDistribute_MPIAIJ(MPI_Comm comm,Mat gmat,PetscInt
> m,MatReuse reuse,Mat *inmat)
>
>
>
>     Barry
>
>
>
> >
> >
> > Thanks a lot.
> >
> > Regards,
> > Yujie
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20080304/cdb70c2b/attachment.htm>


More information about the petsc-users mailing list