[petsc-users] matrix reordering
On Fri, Oct 19, 2012 at 6:03 PM, Mohammad Mirzadeh mirzadeh at gmail.comwrote: Cool. Jed, could you please point me to an example/tutorial for this? I'm going to give it a shot. This works for SeqAIJ: ierr = MatGetOrdering(A,ordering,rowperm,colperm);CHKERRQ(ierr); ierr = MatPermute(A,rowperm,colperm,Aperm);CHKERRQ(ierr); ierr = VecPermute(b,colperm,PETSC_FALSE);CHKERRQ(ierr); ierr = KSPSetOperators(ksp,Aperm,Aperm,DIFFERENT_NONZERO_PATTERN);CHKERRQ(ierr); ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr); ierr = VecPermute(x,rowperm,PETSC_TRUE);CHKERRQ(ierr); Now x is the solution back in the original ordering. There is an example in petsc-dev now. https://bitbucket.org/petsc/petsc-dev/src/tip/src/ksp/ksp/examples/tutorials/ex18.c It should work with petsc-3.3 in serial, but you need petsc-dev for parallel MatPermute. Thanks On Fri, Oct 19, 2012 at 3:57 PM, Jed Brown jedbrown at mcs.anl.gov wrote: _You_ can compute a MatOrdering, MatPermute and VecPermute, solve, and permute back. Profile and if the solve is faster, go ahead and lift the ordering code back into your mesh. On Fri, Oct 19, 2012 at 5:48 PM, Mohammad Mirzadeh mirzadeh at gmail.comwrote: Thanks Barry. I think I agree with you that right way to do it is through mesh setup. As a matter of fact I have done that for some of my problems. Yet, I can think of situations where that kind of support might be beneficial, especially if someone (a.k.a me in this case!) is looking for a 'dirty and fast' fix. Anyway, I still believe that in long term, one should do the partitioning in a pre-processing step anyways and so there may not be much incentive for adding such a support. Thanks again, Mohammad On Fri, Oct 19, 2012 at 3:00 PM, Barry Smith bsmith at mcs.anl.gov wrote: Mohammad, We've thought about adding this kind of support this over the years but always came to the conclusion that the right way to do it is during the mesh setup step. Barry On Oct 19, 2012, at 4:16 PM, Mohammad Mirzadeh mirzadeh at gmail.com wrote: Hi guys, Quick question. *After* the matrix is setup, is it possible to ask PETSc to renumber the nodes internally in the KSPSolve phase to minimize communications for MatMul inside the solver? Can I use the MatPartitioning object for this or is that only intended to partition the mesh as a pre-processing step? Thanks -- next part -- An HTML attachment was scrubbed... URL: http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20121020/872c9b46/attachment.html
[petsc-users] matrix reordering
Awesome. Thanks for doing this Jed. On Sat, Oct 20, 2012 at 5:38 PM, Jed Brown jedbrown at mcs.anl.gov wrote: On Fri, Oct 19, 2012 at 6:03 PM, Mohammad Mirzadeh mirzadeh at gmail.comwrote: Cool. Jed, could you please point me to an example/tutorial for this? I'm going to give it a shot. This works for SeqAIJ: ierr = MatGetOrdering(A,ordering,rowperm,colperm);CHKERRQ(ierr); ierr = MatPermute(A,rowperm,colperm,Aperm);CHKERRQ(ierr); ierr = VecPermute(b,colperm,PETSC_FALSE);CHKERRQ(ierr); ierr = KSPSetOperators(ksp,Aperm,Aperm,DIFFERENT_NONZERO_PATTERN);CHKERRQ(ierr); ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr); ierr = VecPermute(x,rowperm,PETSC_TRUE);CHKERRQ(ierr); Now x is the solution back in the original ordering. There is an example in petsc-dev now. https://bitbucket.org/petsc/petsc-dev/src/tip/src/ksp/ksp/examples/tutorials/ex18.c It should work with petsc-3.3 in serial, but you need petsc-dev for parallel MatPermute. Thanks On Fri, Oct 19, 2012 at 3:57 PM, Jed Brown jedbrown at mcs.anl.gov wrote: _You_ can compute a MatOrdering, MatPermute and VecPermute, solve, and permute back. Profile and if the solve is faster, go ahead and lift the ordering code back into your mesh. On Fri, Oct 19, 2012 at 5:48 PM, Mohammad Mirzadeh mirzadeh at gmail.comwrote: Thanks Barry. I think I agree with you that right way to do it is through mesh setup. As a matter of fact I have done that for some of my problems. Yet, I can think of situations where that kind of support might be beneficial, especially if someone (a.k.a me in this case!) is looking for a 'dirty and fast' fix. Anyway, I still believe that in long term, one should do the partitioning in a pre-processing step anyways and so there may not be much incentive for adding such a support. Thanks again, Mohammad On Fri, Oct 19, 2012 at 3:00 PM, Barry Smith bsmith at mcs.anl.govwrote: Mohammad, We've thought about adding this kind of support this over the years but always came to the conclusion that the right way to do it is during the mesh setup step. Barry On Oct 19, 2012, at 4:16 PM, Mohammad Mirzadeh mirzadeh at gmail.com wrote: Hi guys, Quick question. *After* the matrix is setup, is it possible to ask PETSc to renumber the nodes internally in the KSPSolve phase to minimize communications for MatMul inside the solver? Can I use the MatPartitioning object for this or is that only intended to partition the mesh as a pre-processing step? Thanks -- next part -- An HTML attachment was scrubbed... URL: http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20121020/ee30dd89/attachment.html
[petsc-users] matrix reordering
Hi guys, Quick question. *After* the matrix is setup, is it possible to ask PETSc to renumber the nodes internally in the KSPSolve phase to minimize communications for MatMul inside the solver? Can I use the MatPartitioning object for this or is that only intended to partition the mesh as a pre-processing step? Thanks -- next part -- An HTML attachment was scrubbed... URL: http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20121019/a63d53e5/attachment.html
[petsc-users] matrix reordering
_You_ can compute a MatOrdering, MatPermute and VecPermute, solve, and permute back. Profile and if the solve is faster, go ahead and lift the ordering code back into your mesh. On Fri, Oct 19, 2012 at 5:48 PM, Mohammad Mirzadeh mirzadeh at gmail.comwrote: Thanks Barry. I think I agree with you that right way to do it is through mesh setup. As a matter of fact I have done that for some of my problems. Yet, I can think of situations where that kind of support might be beneficial, especially if someone (a.k.a me in this case!) is looking for a 'dirty and fast' fix. Anyway, I still believe that in long term, one should do the partitioning in a pre-processing step anyways and so there may not be much incentive for adding such a support. Thanks again, Mohammad On Fri, Oct 19, 2012 at 3:00 PM, Barry Smith bsmith at mcs.anl.gov wrote: Mohammad, We've thought about adding this kind of support this over the years but always came to the conclusion that the right way to do it is during the mesh setup step. Barry On Oct 19, 2012, at 4:16 PM, Mohammad Mirzadeh mirzadeh at gmail.com wrote: Hi guys, Quick question. *After* the matrix is setup, is it possible to ask PETSc to renumber the nodes internally in the KSPSolve phase to minimize communications for MatMul inside the solver? Can I use the MatPartitioning object for this or is that only intended to partition the mesh as a pre-processing step? Thanks -- next part -- An HTML attachment was scrubbed... URL: http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20121019/e3a39862/attachment.html
[petsc-users] matrix reordering
Cool. Jed, could you please point me to an example/tutorial for this? I'm going to give it a shot. Thanks On Fri, Oct 19, 2012 at 3:57 PM, Jed Brown jedbrown at mcs.anl.gov wrote: _You_ can compute a MatOrdering, MatPermute and VecPermute, solve, and permute back. Profile and if the solve is faster, go ahead and lift the ordering code back into your mesh. On Fri, Oct 19, 2012 at 5:48 PM, Mohammad Mirzadeh mirzadeh at gmail.comwrote: Thanks Barry. I think I agree with you that right way to do it is through mesh setup. As a matter of fact I have done that for some of my problems. Yet, I can think of situations where that kind of support might be beneficial, especially if someone (a.k.a me in this case!) is looking for a 'dirty and fast' fix. Anyway, I still believe that in long term, one should do the partitioning in a pre-processing step anyways and so there may not be much incentive for adding such a support. Thanks again, Mohammad On Fri, Oct 19, 2012 at 3:00 PM, Barry Smith bsmith at mcs.anl.gov wrote: Mohammad, We've thought about adding this kind of support this over the years but always came to the conclusion that the right way to do it is during the mesh setup step. Barry On Oct 19, 2012, at 4:16 PM, Mohammad Mirzadeh mirzadeh at gmail.com wrote: Hi guys, Quick question. *After* the matrix is setup, is it possible to ask PETSc to renumber the nodes internally in the KSPSolve phase to minimize communications for MatMul inside the solver? Can I use the MatPartitioning object for this or is that only intended to partition the mesh as a pre-processing step? Thanks -- next part -- An HTML attachment was scrubbed... URL: http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20121019/1e9bd615/attachment.html
[petsc-users] Matrix Reordering
Dear all, How can I use the result ( rperm and cperm ) of MatGetOrdering( Mat mat, const MatOrderingType type, IS *rperm, IS *cperm ) as an array of integers in order to permute my own Matrix? Thanks a lot, Behzad -- == Behzad Baghapour Ph.D. Candidate, Mechecanical Engineering University of Tehran, Tehran, Iran https://sites.google.com/site/behzadbaghapour Fax: 0098-21-88020741 == -- next part -- An HTML attachment was scrubbed... URL: http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110929/01d1315a/attachment.htm
[petsc-users] Matrix Reordering
On Sep 29, 2011, at 6:24 AM, behzad baghapour wrote: Dear all, How can I use the result ( rperm and cperm ) of MatGetOrdering( Mat mat, const MatOrderingType type, IS *rperm, IS *cperm ) as an array of integers in order to permute my own Matrix? MatPermute() gives you a new matrix in the new ordering. But note that mostly these routines are used internally and automatically by the -pc_type lu direct solver. You can use ISGetIndices() to get back out of the IS the raw list of integers that you can use in any way you like, Barry Thanks a lot, Behzad -- == Behzad Baghapour Ph.D. Candidate, Mechecanical Engineering University of Tehran, Tehran, Iran https://sites.google.com/site/behzadbaghapour Fax: 0098-21-88020741 ==