<div dir="ltr">Thank you very much,<div><br></div><div>So, if I am using <span style="color:rgb(80,0,80);font-size:12.8px">PetscSplitOwnership() and then </span><span style="font-size:12.8px">MatGetOwnershipRange() to be prepared for preallocation, then </span><span style="color:rgb(80,0,80);font-size:12.8px">MatSetSizes(A, local_size, local_size, N, N) should be called with the calculated local_size from </span><span style="color:rgb(80,0,80);font-size:12.8px">PetscSplitOwnership</span><span style="font-size:12.8px">() ?</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Thanks,</span></div><div><span style="font-size:12.8px">Massoud</span></div><div style="color:rgb(80,0,80);font-size:12.8px"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 12, 2016 at 12:35 AM, Jed Brown <span dir="ltr"><<a href="mailto:jed@jedbrown.org" target="_blank">jed@jedbrown.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Massoud Rezavand <<a href="mailto:msdrezavand@gmail.com">msdrezavand@gmail.com</a>> writes:<br>
<br>
> Dear PETSc team,<br>
><br>
> What is the difference between the following two methods to get the local<br>
> dimensions of a square matrix A? If they do the same, which one is<br>
> recommended? Should I use MPI_Scan after both?<br>
<br>
</span>I would typically use 1 because it's fewer calls and automatically uses<br>
the correct communicator. You can use MatGetOwnershipRange() instead of<br>
manually using MPI_Scan.<br>
<div class="HOEnZb"><div class="h5"><br>
> 1)<br>
><br>
> PetscInt local_size = PETSC_DECIDE;<br>
><br>
> MatSetSizes(A, local_size, local_size, N, N);<br>
><br>
><br>
> 2)<br>
><br>
> PetscInt local_size = PETSC_DECIDE;<br>
><br>
> PetscSplitOwnership(PETSC_<wbr>COMM_WORLD, &local_size, &N);<br>
><br>
> MPI_Scan(&local_size, &end_row, 1, MPIU_INT, MPI_SUM, PETSC_COMM_WORLD);<br>
> begin_row = end_row - local_size;<br>
><br>
><br>
> Thanks in advance,<br>
> Massoud<br>
</div></div></blockquote></div><br></div>