cheshirekow
v0.1.0
|
A utility class for calculating properties of the bitonic sort kernels. More...
#include <mpblocks/cuda/bitonic/Sorter.h>
Public Types | |
typedef unsigned int | uint_t |
Public Member Functions | |
void | config () |
configures the sorter for the current cuda device More... | |
void | config (int dev) |
configures the sorter for the specified cuda device More... | |
uint_t | sort (KeyType *d_DstKey, ValueType *d_DstVal, KeyType *d_SrcKey, ValueType *d_SrcVal, uint_t arrayLength, Direction dir=Ascending) |
actually perform the sort More... | |
Sorter (KeyType min, KeyType max) | |
the constructor queries the current device and calculates relevent parameters to decide how to size the kernels when they're called More... | |
Private Member Functions | |
void | prepare (KeyType *d_SrcKey, uint_t arrayLength, Direction dir) |
used when arrayLength is not a power-of-two, fills the remaining elements with either the min key value of the max key value More... | |
Private Attributes | |
KeyType | m_max |
KeyType | m_min |
uint_t | m_nSM |
number of SMs of the current device More... | |
uint_t | m_sharedLength |
the size (in elements) of shared memory buffers in all the kernels (also, 2x the number of threads in a block) More... | |
uint_t | m_threadsMerge |
number of threads per block to use in the global merge kernel More... | |
uint_t | m_threadsPrepare |
number of threads per block to use in the prepare kernel More... | |
A utility class for calculating properties of the bitonic sort kernels.
The sorter object calculates how much shared memory and how many threads the kernels should use to maximize efficiency. These values are calculated based on attributes of the kerenels and compared to the specifics of the active device at runtime. These values are used to size the grid and the blocks in the grid for the kernel calls
Note that the bitonic sort algorithm only works for arrays which are power-of-two in length. The Sorter class will automatically grow smaller arrays into the next power-of-two so that the bitonic sort algorithm can be used
Note that KeyType
must have a specialization of std::numeric_limits or the prepare kernel wont know how to fill in the rest of the array. There must also exist an operator< (less-than operator, i.e. "<") defined for KeyType
KeyType | the type (class) that the keys to sort |
ValueType | the type (class) of the values associated with keys |
typedef unsigned int mpblocks::cuda::bitonic::Sorter< KeyType, ValueType >::uint_t |
mpblocks::cuda::bitonic::Sorter< KeyType, ValueType >::Sorter | ( | KeyType | min, |
KeyType | max | ||
) |
the constructor queries the current device and calculates relevent parameters to decide how to size the kernels when they're called
Definition at line 46 of file Sorter.cu.hpp.
void mpblocks::cuda::bitonic::Sorter< KeyType, ValueType >::config | ( | ) |
configures the sorter for the current cuda device
Definition at line 56 of file Sorter.cu.hpp.
void mpblocks::cuda::bitonic::Sorter< KeyType, ValueType >::config | ( | int | dev | ) |
configures the sorter for the specified cuda device
Definition at line 63 of file Sorter.cu.hpp.
|
private |
used when arrayLength is not a power-of-two, fills the remaining elements with either the min key value of the max key value
Definition at line 180 of file Sorter.cu.hpp.
uint_t mpblocks::cuda::bitonic::Sorter< KeyType, ValueType >::sort | ( | KeyType * | d_DstKey, |
ValueType * | d_DstVal, | ||
KeyType * | d_SrcKey, | ||
ValueType * | d_SrcVal, | ||
uint_t | arrayLength, | ||
Direction | dir = Ascending |
||
) |
actually perform the sort
[out] | *d_DstKey | the output array for sorted keys |
[out] | *d_DstVal | the output array for sorted values |
[in] | *d_SrcKey | pointer to start of intput array for keys |
[in] | *d_SrcVal | pointer to start of input array for values |
[in] | arrayLength | the size of the array to sort |
[in] | dir | whether to sort ascending or descending) |
Definition at line 143 of file Sorter.cu.hpp.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |