Skip to content

Getting starting index of groups within dataset - ReduceByKey #1333

Closed Answered by elstehle
stndbye asked this question in CUB
Discussion options

You must be logged in to vote

Hello @stndbye and thanks for reaching out!

Great to hear you are getting started with CUB!

You have already correctly identified a great solution to the problem you're trying to solve by using cub's cub::DeviceReduce::ReduceByKey algorithm.

And you have correctly questioned whether you would really need to materialize the integer sequence [0, 1, 2, ..., n]. Good news: You don't have to materialize that sequence.

CUB offers fancy iterators to accomplish tasks like the one you have outlined. In your specific case, you can make use of cub::CountingInputIterator that returns i when the i-th element is dereferenced.

I have put together a sample usage here.

Worth noting, most CUB algorithms su…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
5 replies
@pauleonix
Comment options

@pauleonix
Comment options

@miscco
Comment options

@elstehle
Comment options

@stndbye
Comment options

Answer selected by stndbye
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
CUB
Labels
None yet
4 participants