[petsc-dev] Slowness of PetscSortIntWithArrayPair in MatAssembly

Zhang, Junchao jczhang at mcs.anl.gov
Tue Jul 2 13:23:42 CDT 2019

Is it because the array is already sorted?
--Junchao Zhang

On Tue, Jul 2, 2019 at 12:13 PM Fande Kong via petsc-dev <petsc-dev at mcs.anl.gov<mailto:petsc-dev at mcs.anl.gov>> wrote:
Hi Developers,

John just noticed that the matrix assembly was slow when having sufficient amount of off-diagonal entries. It was not a MPI issue since I was  able to reproduce the issue using two cores on my desktop, that is, "mpirun -n 2".

I turned  on a profiling, and 99.99% of the time was spent on PetscSortIntWithArrayPair (recursively calling).   It took THREE MINUTES  to get the assembly done. And then changed to use the option "-matstash_legacy" to restore
the code to the old assembly routine, and the same code took ONE SECOND to get the matrix assembly done.

Should write any better sorting algorithms?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20190702/6e364fb5/attachment.html>

More information about the petsc-dev mailing list