[petsc-users] How to parallelize a linear system solver A*x=q in a scalar code

Jed Brown jed at jedbrown.org
Mon Oct 13 21:00:30 CDT 2014


Valerio Grazioso <graziosov at libero.it> writes:

> Dear All,
> I have to parallelize an old fortran77-fortran90 cfd scalar

By "scalar", do you mean "serial"?

> code. Before starting from scratch, I decided to parallelize “just”
> the pressure solver (for instance a linear system solver A*x=q).
> Because of the subroutines call tree, and in particular for the fact a
> lot of subroutines are doing some output, it would be of great help if
> I could let just one process run trough the main, leaving all the
> others on hold (with an MPI_Barrier), just to the point where I create
> an MPI matrix (an MPI vectors as well) with MatCreate, and then
> resolve the “parallel” system. Is this plan feasible with petsc ?

You can create parallel objects, but call MatSetValues and VecSetValues
only from rank 0 (where the rest of the code runs).  When done, call
MatAssemblyBegin/MatAssemblyEnd and VecAssemblyBegin/VecAssemblyEnd
collectively.  PETSc will communicate the data where it needs to go.

Be warned that this is totally non-scalable and cannot provide more than
a small speedup.

  https://en.wikipedia.org/wiki/Amdahl%27s_law

Indeed, depending on the problem configuration and the algorithms used
by the current implementation, you might get more speedup in the by
implementing a quality geometric multigrid solver in the serial code
than by "parallelizing" only this bit.

If the present code uses good algorithms, I would encourage doing the
hard work of making it fully parallel as soon as possible.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20141013/098af6f1/attachment.pgp>


More information about the petsc-users mailing list