[petsc-users] Parallel sort in Petsc

Matthew Knepley knepley at gmail.com
Tue Jul 7 09:09:30 CDT 2020


On Tue, Jul 7, 2020 at 9: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?
>

I looked at the code. It does not depend on the value type do you could
just copy it and replace all the Int types with Real. It would be nice to
abstract the type and comparator away, but that is more work in C.

  Thanks,

     Matt


> Thank you very much!
>
> Antoine Côté
>
>
>

-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20200707/c033b757/attachment.html>


More information about the petsc-users mailing list