cheshirekow  v0.1.0
mpblocks::cuda::bitonic::Sorter< KeyType, ValueType > Class Template Reference

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...
 

Detailed Description

template<typename KeyType, typename ValueType = void>
class mpblocks::cuda::bitonic::Sorter< KeyType, ValueType >

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

Template Parameters
KeyTypethe type (class) that the keys to sort
ValueTypethe type (class) of the values associated with keys
See Also
http://www.iti.fh-flensburg.de/lang/algorithmen/sortieren/bitonic/bitonicen.htm

Definition at line 71 of file Sorter.h.

Member Typedef Documentation

template<typename KeyType, typename ValueType = void>
typedef unsigned int mpblocks::cuda::bitonic::Sorter< KeyType, ValueType >::uint_t

Definition at line 74 of file Sorter.h.

Constructor & Destructor Documentation

template<typename KeyType, typename ValueType >
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.

Member Function Documentation

template<typename KeyType , typename ValueType >
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.

template<typename KeyType , typename ValueType >
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.

template<typename KeyType, typename ValueType >
void mpblocks::cuda::bitonic::Sorter< KeyType, ValueType >::prepare ( KeyType *  d_SrcKey,
uint_t  arrayLength,
Direction  dir 
)
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.

template<typename KeyType, typename ValueType>
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

Parameters
[out]*d_DstKeythe output array for sorted keys
[out]*d_DstValthe output array for sorted values
[in]*d_SrcKeypointer to start of intput array for keys
[in]*d_SrcValpointer to start of input array for values
[in]arrayLengththe size of the array to sort
[in]dirwhether to sort ascending or descending)

Definition at line 143 of file Sorter.cu.hpp.

Member Data Documentation

template<typename KeyType, typename ValueType = void>
KeyType mpblocks::cuda::bitonic::Sorter< KeyType, ValueType >::m_max
private

Definition at line 87 of file Sorter.h.

template<typename KeyType, typename ValueType = void>
KeyType mpblocks::cuda::bitonic::Sorter< KeyType, ValueType >::m_min
private

Definition at line 86 of file Sorter.h.

template<typename KeyType, typename ValueType = void>
uint_t mpblocks::cuda::bitonic::Sorter< KeyType, ValueType >::m_nSM
private

number of SMs of the current device

Definition at line 84 of file Sorter.h.

template<typename KeyType, typename ValueType = void>
uint_t mpblocks::cuda::bitonic::Sorter< KeyType, ValueType >::m_sharedLength
private

the size (in elements) of shared memory buffers in all the kernels (also, 2x the number of threads in a block)

Definition at line 77 of file Sorter.h.

template<typename KeyType, typename ValueType = void>
uint_t mpblocks::cuda::bitonic::Sorter< KeyType, ValueType >::m_threadsMerge
private

number of threads per block to use in the global merge kernel

Definition at line 82 of file Sorter.h.

template<typename KeyType, typename ValueType = void>
uint_t mpblocks::cuda::bitonic::Sorter< KeyType, ValueType >::m_threadsPrepare
private

number of threads per block to use in the prepare kernel

Definition at line 80 of file Sorter.h.


The documentation for this class was generated from the following files: