<div class="gmail_quote">On Thu, Sep 1, 2011 at 10:46, Likun Tan <span dir="ltr"><<a href="mailto:likunt@andrew.cmu.edu">likunt@andrew.cmu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div id=":18n">I tried to use<br>
<div class="im">PetscSplitOwnership(PETSC_COMM_WORLD,&n,&N);<br>
MatCreateSeqDense(PETSC_COMM_SELF,M,n,PETSC_NULL,&B);<br>
<br>
</div>But it seems not working. This command is make B store in N/n processors<br>
with n columns in each processor?</div></blockquote><div><br></div><div>B (in the code) is a different matrix on each process. You should fill the columns so that each process has part of B (the logical thing you are working with).</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div id=":18n"> I try to calculate the N/n parts in<br>
parallel, but when i apply MatGetOwnershipRange(), i found the matrix will<br>
be automatically partitioned by row.<br></div></blockquote><div><br></div><div>MatGetOwnershipRange() just gives you the rows from 0 to 26. You need to sum the column partition that was computed earlier. The most explicit way to do that is</div>
<div><br></div><div>PetscInt cstart;</div><div>MPI_Scan(&n,&cstart,1,MPIU_INT,MPI_SUM,PETSC_COMM_WORLD);</div><div>cstart -= n;</div><div><br></div><div>Now each process should compute columns of the logical B in the range [cstart,cstart+n). The B object in your code will indexed [0,n) on each process, but these columns correspond to [cstart,cstart+n).</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div id=":18n">
That's why i go back to use MatCreate() to create a 200*27 matrix and try<br>
to get the tranpose of it.I used<br>
MatCreateSeqDense(PETSC_COMM_SELF, M, N, PETSC_NULL, &C)<br>
to create C, there is no partition of C, i guess this is the reason of the<br>
error.</div></blockquote><div><br></div><div>Don't go down this route, it doesn't do what you want. </div></div><br>