[petsc-users] Understanding MatCreate bsize parameter

Matthew Knepley knepley at gmail.com
Thu Mar 26 09:08:51 CDT 2015


On Thu, Mar 26, 2015 at 8:16 AM, Florian Lindner <mailinglists at xgm.de>
wrote:

> Hello,
>
> I'm using petsc with petsc4py.
>
> A matrix is created like that
>
>     MPIrank = MPI.COMM_WORLD.Get_rank()
>     MPIsize = MPI.COMM_WORLD.Get_size()
>     print("MPI Rank = ", MPIrank)
>     print("MPI Size = ", MPIsize)
>     parts = partitions()
>
>     print("Dimension= ", nSupport + dimension, "bsize = ",
> len(parts[MPIrank]))
>
>     MPI.COMM_WORLD.Barrier() # Just to keep the output together
>     A = PETSc.Mat(); A.createDense( (nSupport + dimension, nSupport +
> dimension), bsize = len(parts[MPIrank]) ) # <-- crash here
>
>
> Output for mpirun -n 2 is like that and it works:
>
> MPI Rank =  0
> MPI Size =  2
> Dimension=  10 bsize =  5
> MPI Rank =  1
> MPI Size =  2
> Dimension=  10 bsize =  5
>
> But for mpirun -n 3 it crashes:
>
> MPI Rank =  2
> MPI Size =  3
> Dimension=  10 bsize =  3
> MPI Rank =  1
> MPI Size =  3
> Dimension=  10 bsize =  4
> MPI Rank =  0
> MPI Size =  3
> Dimension=  10 bsize =  3
>
> Error is ValueError: global size 10 not divisible by block size 3.
>
> I tried to dig a bit into the source. Mat_Create uses Mat_Dense to unpack
> the size and bsize parameters. When there just a scalar n, not a tuple t
> given as parameter it assumes t = (n, n). (Right?). That should be fine.
>
> When I omit bsize, and mpirun -n 3, A.owner_range returns
>
> (4, 7)
> (0, 4)
> (7, 10)
>
> Which essentially is the same partioning that I manually set (I need to
> set partioning manually). Also the sum of bsizes equals the dimension. What
> is the problem here?
>

This looks to me like the lack of an error check. A global size not
divisible by the block size makes no sense at all.

  Thanks,

     Matt


> Thanks,
> Florian
>



-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20150326/aaf4a327/attachment.html>


More information about the petsc-users mailing list