On Tue, Jul 5, 2011 at 2:04 PM, Stefan Kolb <span dir="ltr"><<a href="mailto:skolb@rocketmail.com">skolb@rocketmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi all,<br>
i have written a littel test program, to check how PETSc stores a matrix across two processes.<br>
<br>
static char help[] = "PETSc test";<br>
<br>
#include "stdio.h"<br>
<br>
#include "petscksp.h"<br>
<br>
int main(int argc,char **args)<br>
{<br>
Mat A;<br>
PetscInt N=100,M=100, row_start = 0, column_start = 0, row_end = 0, column_end = 0, rank = 0, local_rows = 0, local_columns = 0,nproc=0;<br>
PetscErrorCode ierr;<br>
PetscScalar value =0.;<br>
<br>
PetscInitialize(&argc,&args,(char *)0,help);<br>
<br>
MPI_Comm_rank(PETSC_COMM_WORLD,&rank);<br>
MPI_Comm_size(PETSC_COMM_WORLD,&nproc);<br>
<br>
ierr = PetscPrintf(PETSC_COMM_WORLD,"Number of Processes %d\n",nproc);CHKERRQ(ierr);<br>
ierr = MatCreate(PETSC_COMM_WORLD,&A); CHKERRQ(ierr);<br>
ierr = MatSetSizes(A,PETSC_DECIDE, PETSC_DECIDE,N,M); CHKERRQ(ierr);<br>
ierr = MatSetFromOptions(A);CHKERRQ(ierr);<br>
ierr = MatGetOwnershipRange(A,&row_start,&row_end);CHKERRQ(ierr);<br>
ierr = MatGetOwnershipRangeColumn(A,&column_start,&column_end);CHKERRQ(ierr);<br>
ierr = MatGetLocalSize(A,&local_rows,&local_columns);CHKERRQ(ierr);<br>
<br>
printf("process=%d \t row_start=%d \t row_end=%d \t column_start=%d \t column_end=%d \t local_rows=%d \t local_columns=%d\n",rank,row_start,row_end,column_start,column_end,local_rows,local_columns);<br>
<br>
ierr = MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);<br>
ierr = MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);<br>
<br>
ierr = MatDestroy(A); CHKERRQ(ierr);<br>
<br>
ierr = PetscFinalize();CHKERRQ(ierr);<br>
return 0;<br>
}<br>
<br>
The output of the program (using 2 processes) is:<br>
Number of Processes 2<br>
process=0 row_start=0 row_end=50 column_start=0 column_end=50 local_rows=50 local_columns=50<br>
process=1 row_start=50 row_end=100 column_start=50 column_end=100 local_rows=50 local_columns=50<br>
<br>
So if the output of my program is right the process with rank=0 owns a matrix with 50 rows and 50 columns in the same way the process with rank=1. This cant be right because on both processes only one half of the global matrix is stored. Wat is the error in my test programm?<br>
I tried to set the local size of the matrix by hand with the command MatSetSizes(A,50, 100,N,M) but then i get an error from PETSc. How can i tell PETSc to store the first 50 rows on process 0 and the next 50 rows on process 1?<br>
</blockquote><div><br></div><div>All matrix formats store by row. The column ownership is only used to determine compatibility with vector it might act on.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Regards,<br>
<font color="#888888">Stefan<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener<br>