[petsc-users] Read in sequential, solve in parallel

Leo van Kampenhout lvankampenhout at gmail.com
Wed Sep 29 07:01:48 CDT 2010


I have run into this same problem some weeks ago. The idea as described by
Jed is that you read in the matrix only once, sequentially, from the
original file. After doing this, you can store the Mat file in Petsc binary
format with MatView. Now for all subsequent runs you can use this binary
file to read in the matrix in parallel, with MatLoad. Good luck,

Leo


2010/9/29 Satish Balay <balay at mcs.anl.gov>

> check mat/examples/tests/ex72.c,ex50.c for examples.
>
> Also ksp/ksp/examples/tutorials/ex10.c - for loading up this matrix
> and solving parallely.
>
> Satish
>
> On Wed, 29 Sep 2010, Jed Brown wrote:
>
> > On Wed, Sep 29, 2010 at 11:46, Moinier, Pierre (UK)
> > <Pierre.Moinier at baesystems.com> wrote:
> > > I have a Matrix and a Right Hand Side (RHS) in an ASCII format stored
> in 2
> > > different files. I have written the code that reads the data and solve
> the
> > > system in sequential. I would like to solve the same problem in
> parallel. I
> > > read the FAQ section that says:
> > >
> > > Never read or write in parallel an ASCII matrix file, instead for
> reading:
> > > read in sequentially then save the matrix with the binary viewer
> > > PetscBinaryViewerOpen() and load the matrix in parallel with MatLoad().
> > >
> > > So far, I did not manage to implement this. Could any one help me?
> >
> > With your matrix assembled in serial:
> >
> >     ierr =
> PetscViewerBinaryOpen(PETSC_COMM_WORLD,"A.dat",FILE_MODE_WRITE,&viewer);CHKERRQ(ierr);
> >     ierr = MatView(A,viewer);CHKERRQ(ierr);
> >     ierr = PetscViewerDestroy(viewer);CHKERRQ(ierr);
> >
> > In parallel:
> >
> >     ierr =
> PetscViewerBinaryOpen(PETSC_COMM_WORLD,"A.dat",FILE_MODE_READ,&viewer);CHKERRQ(ierr);
> >     ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr);
> >     ierr = MatLoad(A,viewer);CHKERRQ(ierr);
> >     ierr = PetscViewerDestroy(viewer);CHKERRQ(ierr);
> >     ierr =
> KSPSetOperators(ksp,A,A,DIFFERENT_NONZERO_PATTERN);CHKERRQ(ierr);
> >
> >
> > Jed
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20100929/b113ff4a/attachment-0001.htm>


More information about the petsc-users mailing list