[petsc-users] KSP ex2.c and Parallelization

Maahi Talukder maahi.buet at gmail.com
Fri Feb 15 16:26:09 CST 2019


Thank you so much for your reply.

But in the definition of d_nz of *MatMPIAIJSetPreallocation  *, it is
defined as 'number of nonzeros per row in DIAGONAL portion of local
submatrix'. So I was wondering about how to find the Diagonal portion of
the local submatrix that PETSc is splitting the big matrix into . So should
it be the maximum number of nonzeros in each row of the big matrix instead
of  the min number of nonzeros in the diagonal portion of the local matrix?

And so MatGetOwnershipRange returns the start and the end of all the
smaller matrices that PETSc is splitting the big matrix into, right?


Regards,
Maahi Talukder

On Fri, Feb 15, 2019 at 2:43 PM Zhang, Hong <hzhang at mcs.anl.gov> wrote:

> Maahi :
>
>> Hello All,
>>
>> I have some questions regarding ex2.c in /
>> *petsc/src/ksp/ksp/examples/tutorials/ex2.c. *
>>
>> 1.   The  local sizes of the matrix was decided by PETSc using *ierr =
>> MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,m*n,m*n);CHKERRQ(ierr);*
>> But without knowing the local sizes, how was the following function used
>> which requires the knowledge of how the big matrix was split into smaller
>> chunks within PETSc?
>>   *ierr = MatMPIAIJSetPreallocation(A,5,NULL,5,NULL);CHKERRQ(ierr);*
>>
> This example sets a matrix for 2D 5-point PDE stencil, for which the
> maximum non-zeros in each row is 5.
>
>>
>> 2.  When using  *MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr),  *the
>> global index of  first and last row of which local chunk of the big matrix
>> is it returning ? I mean if the big matrix was split into three processes,
>> for example, fist and last global row of which process is it returning?
>>
> Adding a line
>   ierr = MatGetOwnershipRange(A,&Istart,&Iend);CHKERRQ(ierr);
> +  printf("Istart %d Iend %d\n",Istart,Iend);
>
> I get
> $ mpiexec -n 3 ./ex2
> Istart 0 Iend 19
> Istart 19 Iend 38
> Istart 38 Iend 56
> Norm of error 0.000522061 iterations 9
> The matrix global size = 56
>
> Hong
>
>>
>> Your replies are highly appreciated
>>
>> Thanks,
>> Maahi Talukder
>> Clarkson University
>>
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20190215/3e070761/attachment.html>


More information about the petsc-users mailing list