-
Hello, I'm just learning about CUB, so i don't have much knowledge about the library. I have a list of non unique sorted keys, and i would like to produce the first index for each key. Is there a way to avoid storing the value array - and somehow just feed the index of the current key as an input value? Or is there another method better suited for this task? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
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 And you have correctly questioned whether you would really need to materialize the integer sequence CUB offers fancy iterators to accomplish tasks like the one you have outlined. In your specific case, you can make use of I have put together a sample usage here. Worth noting, most CUB algorithms support fancy iterators, and you can use fancy iterators wherever you would use a CUDA array. I hope this helps. Please let us know if you have any follow up questions. |
Beta Was this translation helpful? Give feedback.
-
Thanks for confirming the solution worked for you. Closing the issue as resolved. |
Beta Was this translation helpful? Give feedback.
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 returnsi
when thei-th
element is dereferenced.I have put together a sample usage here.
Worth noting, most CUB algorithms su…