libsc  2.8.7
The SC library provides support for parallel scientific applications.
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Functions
sc_sort.h File Reference

Provide a parallel sort algorithm. More...

#include <sc.h>
Include dependency graph for sc_sort.h:

Go to the source code of this file.

Functions

void sc_psort (sc_MPI_Comm mpicomm, void *base, size_t *nmemb, size_t size, int(*compar)(const void *, const void *))
 Sort a distributed set of fixed-size data items in parallel. More...
 

Detailed Description

Provide a parallel sort algorithm.

We use a variant of the bitonic sort algorithm. Within each process we rely on the system quick sort function. The partition of data on input is arbitrary and remains invariant.

Function Documentation

◆ sc_psort()

void sc_psort ( sc_MPI_Comm  mpicomm,
void *  base,
size_t *  nmemb,
size_t  size,
int(*)(const void *, const void *)  compar 
)

Sort a distributed set of fixed-size data items in parallel.

This algorithm uses bitonic sort between processors and qsort locally.

This function is thread-safe if src/sc_config.h #defines SC_HAVE_QSORT_R. Otherwise, it uses a static read-only variable for the comparison function, and calling sc_psort concurrently is likely to fail.

The partition of the data can be arbitrary and is not changed.

Parameters
[in]mpicommCommunicator to use.
[in]basePointer to the process-local data items.
[in]nmembArray of mpisize counts of data items. For each process, the number of its local items. This array must be identical on all processes.
[in]sizeSize in bytes of one data item.
[in]comparComparison function to use; see man (3) qsort. Shall return < 0 if the first argument is less than the second, 0 if both are equal, and > 0 if the first is greater than the second.