Skip to content

cub::DeviceRunLengthEncode::Encode does not accept thrust::discard_iterator for unique output #784

@fkallen

Description

@fkallen

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
}

https://cuda.godbolt.org/z/cvasqxrbo

/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]" 

Metadata

Metadata

Assignees

Labels

thrustFor all items related to Thrust.

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions