Cython interface to parallel sorting routines
Project description
parallel-sort
This module provides a simple Cython interface to parallel sorting algorithms available in C++. It provides functions for in-place and out-of-place sorts, as well as indirect sorting (aka. "argsort").
By default it requires a C++17-capable compiler, and will use the standard std::sort
routine with the parallel execution policy introduced in that standard. For older compilers without C++17 support, the GNU Parallel Mode sorting routines may be used instead.
Usage
import parallel_sort
import numpy as np
x = np.random.random(size=10000)
x_sorted = parallel_sort.sort(x)
assert np.all(np.diff(x) >= 0) # x is now sorted
Note that these routines are "unstable" sorts, meaning that the ordering of equal elements in the original array is not guaranteed to be preserved.
Installing
Requirements: numpy, C++17-capable g++, Cython (only for installation from source).
On Linux, installing from wheel via pip
should "just work":
pip install parallel_sort
On Mac, it is important to ensure that gcc is used to compile the module rather than the default Apple-provided clang, which can be done by prefixing the install command with CC=$(brew --prefix gcc)/bin/gcc-13
(substituting your gcc version as appropriate).
GNU Parallel Mode option
For older compilers that do not support C++17, the module can use the GNU Parallel Mode library instead. To build without C++17, clone the repository and set use_cxx17 = False
in setup.py
. Then run:
pip install -e .
to compile and install the module.
Note for Apple Silicon Macs
If the module builds OK, but importing it fails with an error "undefined reference to aarch64_ldadd4_acq_rel
", try rebuilding with the following command
CFLAGS=-mno-outline-atomics CC=$(brew --prefix gcc)/bin/gcc-13 pip install --no-cache-dir -e .
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for parallel_sort-0.2.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4628a7e9cd44e54fd61154d8fda122a7237302574367ec7e8711a3a0271f0f85 |
|
MD5 | 456996106bed28c0453d065e1ffdfea7 |
|
BLAKE2b-256 | 5f26c625605d7f7eeaa380149430faf49a1fef3ca8f4a84e590c552ffe821462 |
Hashes for parallel_sort-0.2.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 843718165bc91cedf919ac3e9ba2045714fe2a4cd67f1d3c28f3b4ea380e19d4 |
|
MD5 | 3277ac802ce49e5e870a308213654a6c |
|
BLAKE2b-256 | d8ca166aa10da20a07286e5f113077e178abcb8e95d9527643b590be93ebd4d9 |
Hashes for parallel_sort-0.2.0-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0fc95f644d6b159a76b1e0b3366a0c45e18846ce9fd660de5fff795fa02e9f7 |
|
MD5 | df5c0c80a2a86d927b5f36be6beb2c37 |
|
BLAKE2b-256 | 512e1e3757317b1a21b3e47e9e94ec5524c3b612bf89d3b550f0be4507291904 |
Hashes for parallel_sort-0.2.0-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8bdd2d18dc6329940437aee64a788bc507ca1614eb1ca72221e0c4cb5c5feeeb |
|
MD5 | 0083477386c155db5c9b21f4c9ce0720 |
|
BLAKE2b-256 | 6fe2d4c50078ff84396e8ac543479c4b0bf8853608e127ebf9015c5a2995f3e7 |
Hashes for parallel_sort-0.2.0-cp37-cp37m-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa6f5477c7ae946466d8a05f6531b5879d8fb5f402a7f7075d40114af74004cb |
|
MD5 | 71236b9e9273471450a21b520ca3600c |
|
BLAKE2b-256 | 88d1d1647b718f2d9b8eaf7608fe3da204d1589b8a355fb1cdf7351004bf6632 |