Spaces:
Sleeping
Sleeping
File size: 1,325 Bytes
66c9c8a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | #include "warp.h"
#include <cstdint>
template <typename T>
void runlength_encode_host(int n,
const T *values,
T *run_values,
int *run_lengths,
int *run_count)
{
if (n == 0)
{
*run_count = 0;
return;
}
const T *end = values + n;
*run_count = 1;
*run_lengths = 1;
*run_values = *values;
while (++values != end)
{
if (*values == *run_values)
{
++*run_lengths;
}
else
{
++*run_count;
*(++run_lengths) = 1;
*(++run_values) = *values;
}
}
}
void runlength_encode_int_host(
uint64_t values,
uint64_t run_values,
uint64_t run_lengths,
uint64_t run_count,
int n)
{
runlength_encode_host<int>(n,
reinterpret_cast<const int *>(values),
reinterpret_cast<int *>(run_values),
reinterpret_cast<int *>(run_lengths),
reinterpret_cast<int *>(run_count));
}
#if !WP_ENABLE_CUDA
void runlength_encode_int_device(
uint64_t values,
uint64_t run_values,
uint64_t run_lengths,
uint64_t run_count,
int n)
{
}
#endif |