[petsc-users] Parallel sort in Petsc

Junchao Zhang junchao.zhang at gmail.com
Tue Jul 7 09:52:35 CDT 2020


Gather all values to rank 0 and do a sequential sort there, then profile to
see whether it is a performance bottleneck in your code.

--Junchao Zhang


On Tue, Jul 7, 2020 at 8:14 AM Antoine Côté <Antoine.Cote3 at usherbrooke.ca>
wrote:

> Hi,
>
> I need to compute the permutations to sort scalar values of a Vec object
> in decreasing order. I've been developing on a single process for now,
> using VecGetArrayRead() to extract the values
> and PetscSortRealWithPermutation() to get the permutations.
>
> I would like to run the code on multiple processes. From these links, I
> can see it's an issue :
> https://lists.mcs.anl.gov/pipermail/petsc-users/2013-November/019628.html
> https://lists.mcs.anl.gov/pipermail/petsc-users/2009-June/004621.html
>
> One work around I've been considering : get the max scalar value using
> VecMax() ; compute a scaling factor that makes this max value equals the
> largest integer value tolerated by PetscInt ; scale all values of Vec and
> convert them to integers ; use PetscParallelSortInt() ; inverse the scaling
> on (now sorted) integers values and convert them back to scalars.
>
> This is only a patch really, the main issues being : (1) I would get a
> sorted Vec, not the permutations and (2) there would be a lost of
> information when converting scalars to int values.
>
> Isn't there a way to parallel sort real values using Petsc?
>
> Thank you very much!
>
> Antoine Côté
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20200707/d9f31e0f/attachment.html>


More information about the petsc-users mailing list