One can use a discard iterator for runlength encoding when only the lengths of runs are required. The following code does accept cub::DiscardOutputIterator but not thrust::discard_iterator .
#include <thrust/iterator/discard_iterator.h>
#include <cub/cub.cuh>
int main(){
std::size_t tempbytes = 0;
#if 0
cub::DeviceRunLengthEncode::Encode(
nullptr,
tempbytes,
(int*)nullptr, //data
cub::DiscardOutputIterator<>{}, //unique data
(int*)nullptr, // run lengths
(int*)nullptr, //num runs
0 //num data
);
#else
cub::DeviceRunLengthEncode::Encode(
nullptr,
tempbytes,
(int*)nullptr, //data
thrust::make_discard_iterator(), //unique data
(int*)nullptr, // run lengths
(int*)nullptr, //num runs
0 //num data
);
#endif
}
/opt/compiler-explorer/libs/thrustcub/trunk/cub/block/specializations/../../block/../thread/../thread/thread_operators.cuh(64): error: no operator "==" matches these operands
operand types are: const thrust::detail::any_assign == const thrust::detail::any_assign
detected during:
instantiation of "__nv_bool cub::Equality::operator()(const T &, const T &) const [with T=thrust::detail::any_assign]"
One can use a discard iterator for runlength encoding when only the lengths of runs are required. The following code does accept
cub::DiscardOutputIteratorbut notthrust::discard_iterator.https://cuda.godbolt.org/z/cvasqxrbo