Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

cub::DeviceRadixSort::SortPairs for multiple values #61

Closed
sh1ng opened this issue Oct 14, 2016 · 1 comment
Closed

cub::DeviceRadixSort::SortPairs for multiple values #61

sh1ng opened this issue Oct 14, 2016 · 1 comment

Comments

@sh1ng
Copy link

sh1ng commented Oct 14, 2016

Sorry for a duplicate(https://github.com/NVlabs/cub/issues/40) but it's been closed without fix or workaround.

Suppose I've three arrays/vectors

  • keys
  • values1
  • values2

and I want to sort values1 and values2 by keys.
It can be done by calling SortPairs twice.

Can the running time be improved by putting them in a single sort?
Can you provide a code snippet to do that or implementation require?

@dumerrill
Copy link
Contributor

You could zip values1 and values2 into a single tuple-array (array-of-structures) and then do a single key-value sort. Or you could create a index array (the natural numbers), sort that as the paired values, and then use it as a permutation map to reorder any number of other arrays in a simple gather-scatter kernel.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants