Alien-XGBoost
view release on metacpan or search on metacpan
xgboost/cub/test/test_block_radix_sort.cu view on Meta::CPAN
Key *d_keys,
Value *d_values,
int begin_bit,
int end_bit,
clock_t &stop,
Int2Type<false> is_descending,
Int2Type<false> is_blocked_output)
{
BlockRadixSort(temp_storage).SortBlockedToStriped(keys, values, begin_bit, end_bit);
stop = clock();
StoreDirectStriped<BLOCK_THREADS>(threadIdx.x, d_keys, keys);
StoreDirectStriped<BLOCK_THREADS>(threadIdx.x, d_values, values);
}
/**
* BlockRadixSort kernel
*/
template <
int BLOCK_THREADS,
int ITEMS_PER_THREAD,
int RADIX_BITS,
bool MEMOIZE_OUTER_SCAN,
BlockScanAlgorithm INNER_SCAN_ALGORITHM,
cudaSharedMemConfig SMEM_CONFIG,
int DESCENDING,
int BLOCKED_OUTPUT,
typename Key,
typename Value>
__launch_bounds__ (BLOCK_THREADS, 1)
__global__ void Kernel(
Key *d_keys,
Value *d_values,
int begin_bit,
int end_bit,
clock_t *d_elapsed)
{
// Threadblock load/store abstraction types
typedef BlockRadixSort<
Key,
BLOCK_THREADS,
ITEMS_PER_THREAD,
Value,
RADIX_BITS,
MEMOIZE_OUTER_SCAN,
INNER_SCAN_ALGORITHM,
SMEM_CONFIG>
BlockRadixSortT;
// Allocate temp storage in shared memory
__shared__ typename BlockRadixSortT::TempStorage temp_storage;
// Items per thread
Key keys[ITEMS_PER_THREAD];
Value values[ITEMS_PER_THREAD];
LoadDirectBlocked(threadIdx.x, d_keys, keys);
LoadDirectBlocked(threadIdx.x, d_values, values);
// Start cycle timer
clock_t stop;
clock_t start = clock();
TestBlockSort<BLOCK_THREADS, BlockRadixSortT>(
temp_storage, keys, values, d_keys, d_values, begin_bit, end_bit, stop, Int2Type<DESCENDING>(), Int2Type<BLOCKED_OUTPUT>());
// Store time
if (threadIdx.x == 0)
*d_elapsed = (start > stop) ? start - stop : stop - start;
}
//---------------------------------------------------------------------
// Host testing subroutines
//---------------------------------------------------------------------
/**
* Simple key-value pairing
*/
template <
typename Key,
typename Value,
bool IS_FLOAT = (Traits<Key>::CATEGORY == FLOATING_POINT)>
struct Pair
{
Key key;
Value value;
bool operator<(const Pair &b) const
{
return (key < b.key);
}
};
/**
* Simple key-value pairing (specialized for floating point types)
*/
template <typename Key, typename Value>
struct Pair<Key, Value, true>
{
Key key;
Value value;
bool operator<(const Pair &b) const
{
if (key < b.key)
return true;
if (key > b.key)
return false;
// Key in unsigned bits
typedef typename Traits<Key>::UnsignedBits UnsignedBits;
// Return true if key is negative zero and b.key is positive zero
UnsignedBits key_bits = *reinterpret_cast<UnsignedBits*>(const_cast<Key*>(&key));
UnsignedBits b_key_bits = *reinterpret_cast<UnsignedBits*>(const_cast<Key*>(&b.key));
UnsignedBits HIGH_BIT = Traits<Key>::HIGH_BIT;
( run in 1.778 second using v1.01-cache-2.11-cpan-524268b4103 )