On Thu, Sep 1, 2011 at 10:46, Likun Tan <likunt at andrew.cmu.edu> wrote:
> I tried to use > PetscSplitOwnership(PETSC_COMM_WORLD,&n,&N); > MatCreateSeqDense(PETSC_COMM_SELF,M,n,PETSC_NULL,&B); > > But it seems not working. This command is make B store in N/n processors > with n columns in each processor? > 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). > I try to calculate the N/n parts in > parallel, but when i apply MatGetOwnershipRange(), i found the matrix will > be automatically partitioned by row. > 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 PetscInt cstart; MPI_Scan(&n,&cstart,1,MPIU_INT,MPI_SUM,PETSC_COMM_WORLD); cstart -= n; 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). > That's why i go back to use MatCreate() to create a 200*27 matrix and try > to get the tranpose of it.I used > MatCreateSeqDense(PETSC_COMM_SELF, M, N, PETSC_NULL, &C) > to create C, there is no partition of C, i guess this is the reason of the > error. > Don't go down this route, it doesn't do what you want. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110901/499f586a/attachment.htm>
