Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PETSc interface suggestions #16

Open
jedbrown opened this issue Aug 8, 2017 · 2 comments
Open

PETSc interface suggestions #16

jedbrown opened this issue Aug 8, 2017 · 2 comments

Comments

@jedbrown
Copy link
Contributor

jedbrown commented Aug 8, 2017

The present use of MatGetSubMatrix looks awkward and like it wastes significant memory, particularly when there are several MPI processes per device. MatGetSubMatrices does more precisely what you want -- returning a sequential matrix with full rows only on the processes that request it (processes that are not part of gpuWorld can pass empty index sets).

The use of VecGetArray for the RHS will be problematic in case the RHS has been "locked" (e.g., by a higher level solve in PETSc). I recommend VecGetArrayRead.

@piyueh
Copy link
Member

piyueh commented Aug 9, 2017

Let me see if my understanding is correct: MatGetSubMatrix returns a parallel matrix living on the original communicator, and MatGetSubMatrices returns an array of sequential matrices on each process (and in our case, we only need one sequential matrix, i.e. the length of the array will be one). So MatGetSubMatrix requires more memory because a parallel matrix uses more memory to store additional information even on processes owning no rows?

@jedbrown
Copy link
Contributor Author

jedbrown commented Aug 9, 2017

So MPIAIJ matrices are stored with the diagonal block separate from the off-diagonal block (to overlap communication of the halo needed by the vector). MatMPIAIJGetLocalMat takes that partitioned representation and gives you a single matrix with global column space -- that is a copy. But inside the implementation of MatGetSubMatrix_MPIAIJ, the usage here is currently going to take a path that calls a form of MatGetSubMatrices and converts the unpartitioned representation into MPIAIJ. If you call MatGetSubMatrices directly, you eliminate the memory and overhead of converting the submatrices to partitioned format and back to unpartitioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants