Build and apply spatial permutations for marker-data locality. More...
#include "sorting.hpp"
Public Member Functions | |
| void | apply_integer8 (const Kokkos::View< int64_t ** > &markers, Kokkos::View< int64_t ** > &sorted_markers, int np, int start_att, int end_att, bool nl_revert) |
| Sort or restore signed 64-bit attributes out of place. | |
| void | apply_integer8_inplace (Kokkos::View< int64_t ** > &markers, int np, int start_att, int end_att, bool nl_revert) |
| Sort or restore signed 64-bit attributes in place. | |
| void | apply_logical (const Kokkos::View< bool ** > &markers, Kokkos::View< bool ** > &sorted_markers, int np, int start_att, int end_att, bool nl_revert) |
| Sort or restore logical attributes out of place. | |
| void | apply_logical_inplace (Kokkos::View< bool ** > &markers, int np, int start_att, int end_att, bool nl_revert) |
| Sort or restore logical attributes in place. | |
| void | apply_real (const Kokkos::View< Real ** > &markers, Kokkos::View< Real ** > &sorted_markers, int np, int start_att, int end_att, bool nl_revert) |
| Sort or restore double-precision attributes out of place. | |
| void | apply_real4 (const Kokkos::View< float ** > &markers, Kokkos::View< float ** > &sorted_markers, int np, int start_att, int end_att, bool nl_revert) |
| Sort or restore single-precision attributes out of place. | |
| void | apply_real4_inplace (Kokkos::View< float ** > &markers, int np, int start_att, int end_att, bool nl_revert) |
| Sort or restore single-precision attributes in place. | |
| void | apply_real_inplace (Kokkos::View< Real ** > &markers, int np, int start_att, int end_att, bool nl_revert) |
| Sort or restore double-precision attributes in place. | |
| void | build_permutation (int np, const Kokkos::View< Real * > &x, const Kokkos::View< Real * > &y=Kokkos::View< Real * >(), const Kokkos::View< Real * > &z=Kokkos::View< Real * >()) |
| Bin active markers and build forward and inverse permutations. | |
| const Kokkos::View< int ** > & | get_displs () const |
| Access bin/partition starting offsets. | |
| const Kokkos::View< int * > & | get_inv_permut () const |
| Access the sorted-to-original permutation. | |
| int | get_nbins () const |
| Return the number of regular spatial bins. | |
| const Kokkos::View< int * > & | get_permut () const |
| Access the original-to-sorted permutation. | |
| void | init_device () |
| Device-neutral alias of init_gpu(). | |
| void | init_gpu () |
| Compatibility hook for the former explicit accelerator allocation. | |
| SortingClass (int npalloc, bool nl_inplace, int ndim, Real xmin, Real xmax, int nx, Real ymin=0.0, Real ymax=0.0, int ny=1, Real zmin=0.0, Real zmax=0.0, int nz=1) | |
| Allocate a fixed-capacity regular-grid sorter. | |
| ~SortingClass ()=default | |
| Release Kokkos Views through normal reference-counted destruction. | |
Build and apply spatial permutations for marker-data locality.
The class bins up to npalloc markers in one, two, or three coordinates and constructs mutually inverse mappings between the original order and a bin-contiguous order. The same mapping can then be applied to every typed particle-attribute array, preserving alignment across the complete marker record. Values outside the configured box are grouped in one overflow bin after all regular bins.
Coordinates and bounds use the units of the selected particle variables; the sorter itself performs no normalization. Kernels execute in the active Kokkos execution space and do not communicate between MPI ranks.
| orb5x::SortingClass::SortingClass | ( | int | npalloc, |
| bool | nl_inplace, | ||
| int | ndim, | ||
| Real | xmin, | ||
| Real | xmax, | ||
| int | nx, | ||
| Real | ymin = 0.0, |
||
| Real | ymax = 0.0, |
||
| int | ny = 1, |
||
| Real | zmin = 0.0, |
||
| Real | zmax = 0.0, |
||
| int | nz = 1 |
||
| ) |
Allocate a fixed-capacity regular-grid sorter.
| [in] | npalloc | Maximum active marker count. |
| [in] | nl_inplace | Allocate work arrays needed by apply_*_inplace. |
| [in] | ndim | Number of coordinates, from 1 through 3. |
| [in] | xmin | Lower bound of coordinate 1 (inclusive). |
| [in] | xmax | Upper bound of coordinate 1 (exclusive). |
| [in] | nx | Number of bins in coordinate 1. |
| [in] | ymin | Lower bound of coordinate 2 when ndim >= 2. |
| [in] | ymax | Upper bound of coordinate 2 when ndim >= 2. |
| [in] | ny | Number of bins in coordinate 2. |
| [in] | zmin | Lower bound of coordinate 3 when ndim == 3. |
| [in] | zmax | Upper bound of coordinate 3 when ndim == 3. |
| [in] | nz | Number of bins in coordinate 3. |
| std::runtime_error | For an unsupported dimension, non-positive bin count, or non-increasing bound pair in an active coordinate. |
|
default |
Release Kokkos Views through normal reference-counted destruction.
| void orb5x::SortingClass::apply_integer8 | ( | const Kokkos::View< int64_t ** > & | markers, |
| Kokkos::View< int64_t ** > & | sorted_markers, | ||
| int | np, | ||
| int | start_att, | ||
| int | end_att, | ||
| bool | nl_revert | ||
| ) |
Sort or restore signed 64-bit attributes out of place.
| [in,out] | markers | Original source or restored destination. |
| [in,out] | sorted_markers | Sorted destination or revert source. |
| [in] | np | Number of markers. |
| [in] | start_att | First inclusive attribute column. |
| [in] | end_att | Last inclusive attribute column. |
| [in] | nl_revert | Select restoration when true. |
| void orb5x::SortingClass::apply_integer8_inplace | ( | Kokkos::View< int64_t ** > & | markers, |
| int | np, | ||
| int | start_att, | ||
| int | end_att, | ||
| bool | nl_revert | ||
| ) |
Sort or restore signed 64-bit attributes in place.
| [in,out] | markers | Array to permute. |
| [in] | np | Number of markers. |
| [in] | start_att | First inclusive attribute column. |
| [in] | end_att | Last inclusive attribute column. |
| [in] | nl_revert | Select restoration when true. |
| void orb5x::SortingClass::apply_logical | ( | const Kokkos::View< bool ** > & | markers, |
| Kokkos::View< bool ** > & | sorted_markers, | ||
| int | np, | ||
| int | start_att, | ||
| int | end_att, | ||
| bool | nl_revert | ||
| ) |
Sort or restore logical attributes out of place.
| [in,out] | markers | Original source or restored destination. |
| [in,out] | sorted_markers | Sorted destination or revert source. |
| [in] | np | Number of markers. |
| [in] | start_att | First inclusive attribute column. |
| [in] | end_att | Last inclusive attribute column. |
| [in] | nl_revert | Select restoration when true. |
| void orb5x::SortingClass::apply_logical_inplace | ( | Kokkos::View< bool ** > & | markers, |
| int | np, | ||
| int | start_att, | ||
| int | end_att, | ||
| bool | nl_revert | ||
| ) |
Sort or restore logical attributes in place.
| [in,out] | markers | Array to permute. |
| [in] | np | Number of markers. |
| [in] | start_att | First inclusive attribute column. |
| [in] | end_att | Last inclusive attribute column. |
| [in] | nl_revert | Select restoration when true. |
| void orb5x::SortingClass::apply_real | ( | const Kokkos::View< Real ** > & | markers, |
| Kokkos::View< Real ** > & | sorted_markers, | ||
| int | np, | ||
| int | start_att, | ||
| int | end_att, | ||
| bool | nl_revert | ||
| ) |
Sort or restore double-precision attributes out of place.
| [in,out] | markers | Original-order source when sorting; restored output when nl_revert is true. |
| [in,out] | sorted_markers | Sorted output when sorting; source when reverting. |
| [in] | np | Number of leading markers to transform. |
| [in] | start_att | First attribute column, inclusive and zero-based. |
| [in] | end_att | Last attribute column, inclusive. |
| [in] | nl_revert | False for original-to-sorted; true for sorted-to-original. |
| void orb5x::SortingClass::apply_real4 | ( | const Kokkos::View< float ** > & | markers, |
| Kokkos::View< float ** > & | sorted_markers, | ||
| int | np, | ||
| int | start_att, | ||
| int | end_att, | ||
| bool | nl_revert | ||
| ) |
Sort or restore single-precision attributes out of place.
| [in,out] | markers | Original source or restored destination. |
| [in,out] | sorted_markers | Sorted destination or revert source. |
| [in] | np | Number of markers. |
| [in] | start_att | First inclusive attribute column. |
| [in] | end_att | Last inclusive attribute column. |
| [in] | nl_revert | Select restoration when true. |
| void orb5x::SortingClass::apply_real4_inplace | ( | Kokkos::View< float ** > & | markers, |
| int | np, | ||
| int | start_att, | ||
| int | end_att, | ||
| bool | nl_revert | ||
| ) |
Sort or restore single-precision attributes in place.
| [in,out] | markers | Array to permute. |
| [in] | np | Number of markers. |
| [in] | start_att | First inclusive attribute column. |
| [in] | end_att | Last inclusive attribute column. |
| [in] | nl_revert | Select restoration when true. |
| void orb5x::SortingClass::apply_real_inplace | ( | Kokkos::View< Real ** > & | markers, |
| int | np, | ||
| int | start_att, | ||
| int | end_att, | ||
| bool | nl_revert | ||
| ) |
Sort or restore double-precision attributes in place.
| [in,out] | markers | Marker-major attribute array to permute. |
| [in] | np | Number of leading markers to transform. |
| [in] | start_att | First inclusive zero-based attribute column. |
| [in] | end_att | Last inclusive attribute column. |
| [in] | nl_revert | False to sort; true to restore original order. |
| std::runtime_error | If capacity is exceeded or in-place work storage was not requested at construction. |
| void orb5x::SortingClass::build_permutation | ( | int | np, |
| const Kokkos::View< Real * > & | x, | ||
| const Kokkos::View< Real * > & | y = Kokkos::View< Real * >(), |
||
| const Kokkos::View< Real * > & | z = Kokkos::View< Real * >() |
||
| ) |
Bin active markers and build forward and inverse permutations.
| [in] | np | Number of leading markers to include, at most npalloc. |
| [in] | x | First coordinate, with at least np elements. |
| [in] | y | Second coordinate when configured for two or three dimensions. |
| [in] | z | Third coordinate when configured for three dimensions. |
| std::runtime_error | If np exceeds capacity or a required coordinate view is absent. |
After completion permut[old] gives the sorted index and inv_permut[sorted] gives the original index.
|
inline |
Access bin/partition starting offsets.
[regular-or-overflow bin][logical partition].
|
inline |
Access the sorted-to-original permutation.
inv_permut(sorted_index) is the original index.
|
inline |
Return the number of regular spatial bins.
nx*ny*nz, excluding the additional out-of-bounds bin.
|
inline |
Access the original-to-sorted permutation.
permut(old_index) is the sorted index. | void orb5x::SortingClass::init_device | ( | ) |
Device-neutral alias of init_gpu().
| void orb5x::SortingClass::init_gpu | ( | ) |
Compatibility hook for the former explicit accelerator allocation.