Radix Key Encoder/Decoder#

template<class Key, bool Descending = false, bool is_fundamental = ::rocprim::detail::radix_key_fundamental<Key>::value>
class radix_key_codec : protected rocprim::detail::radix_key_codec_base<Key>#

Key encoder, decoder and bit-extractor for radix-based sorts.

Template Parameters:
  • Key – Type of the key used.

  • Descending – Whether the sort is increasing or decreasing.

Public Types

using bit_key_type = typename base_type::bit_key_type#

Type of the encoded key.

Public Static Functions

template<class Decomposer = ::rocprim::identity_decomposer>
__host__ __device__ static inline bit_key_type encode(Key key, Decomposer decomposer = {})#

Encodes a key of type Key into bit_key_type.

Template Parameters:

Decomposer – Being Key a fundamental type, Decomposer should be identity_decomposer. This is also the type by default.

Parameters:
  • key[in] Key to encode.

  • decomposer[in] [optional] Decomposer functor.

Returns:

A bit_key_type encoded key.

template<class Decomposer = ::rocprim::identity_decomposer>
__host__ __device__ static inline void encode_inplace(Key &key, Decomposer decomposer = {})#

Encodes in-place a key of type Key.

Template Parameters:

Decomposer – Being Key a fundamental type, Decomposer should be identity_decomposer. This is also the type by default.

Parameters:
  • key[inout] Key to encode.

  • decomposer[in] [optional] Decomposer functor.

template<class Decomposer = ::rocprim::identity_decomposer>
__host__ __device__ static inline Key decode(bit_key_type bit_key, Decomposer decomposer = {})#

Decodes an encoded key of type bit_key_type back into Key.

Template Parameters:

Decomposer – Being Key a fundamental type, Decomposer should be identity_decomposer. This is also the type by default.

Parameters:
  • bit_key[in] Key to decode.

  • decomposer[in] [optional] Decomposer functor.

Returns:

A Key decoded key.

template<class Decomposer = ::rocprim::identity_decomposer>
__host__ __device__ static inline void decode_inplace(Key &key, Decomposer decomposer = {})#

Decodes in-place an encoded key of type Key.

Template Parameters:

Decomposer – Being Key a fundamental type, Decomposer should be identity_decomposer. This is also the type by default.

Parameters:
  • key[inout] Key to decode.

  • decomposer[in] [optional] Decomposer functor.

__host__ __device__ static inline unsigned int extract_digit(bit_key_type bit_key, unsigned int start, unsigned int radix_bits)#

Extracts the specified bits from a given encoded key.

Parameters:
  • bit_key[in] Encoded key.

  • start[in] Start bit of the sequence of bits to extract.

  • radix_bits[in] How many bits to extract.

Returns:

Requested bits from the key.

template<class Decomposer = ::rocprim::identity_decomposer>
__host__ __device__ static inline unsigned int extract_digit(Key key, unsigned int start, unsigned int radix_bits, Decomposer decomposer = {})#

Extracts the specified bits from a given in-place encoded key.

Template Parameters:

Decomposer – Being Key a fundamental type, Decomposer should be identity_decomposer. This is also the type by default.

Parameters:
  • key[in] Key.

  • start[in] Start bit of the sequence of bits to extract.

  • radix_bits[in] How many bits to extract.

  • decomposer[in] [optional] Decomposer functor.

Returns:

Requested bits from the key.

template<class Decomposer = ::rocprim::identity_decomposer>
__host__ __device__ static inline Key get_out_of_bounds_key(Decomposer decomposer = {})#

Gives the default value for out-of-bound keys of type Key.

Template Parameters:

Decomposer – Being Key a fundamental type, Decomposer should be identity_decomposer. This is also the type by default.

Parameters:

decomposer[in] [optional] Decomposer functor.

Returns:

Out-of-bound keys’ value.