Skip to content

Is there any way to use cub for multi-keyword sorting? #1459

Answered by elstehle
0x5459 asked this question in CUB
Discussion options

You must be logged in to vote

@pauleonix beat me to it 🚀

Seems like the supported way of radix-sorting custom types is a "decomposer object" according to the docs. Not sure how that is done though.

This is indeed the preferred way of sorting composed sort keys.

I've put together a code sample on how you can use the decomposer object to implement your use case. Let me know if you have any questions about it.

Link to code sample:
https://godbolt.org/z/5dGexEhYo

Code Sample
#include <cstdint>
#include <cuda/std/tuple>
#include <cub/device/device_radix_sort.cuh>
#include <thrust/copy.h>
#include <thrust/sort.h>
#include <thrust/tuple.h>
#include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <thrust/…

Replies: 2 comments 7 replies

Comment options

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

@pauleonix
Comment options

Comment options

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

@pauleonix
Comment options

@0x5459
Comment options

@elstehle
Comment options

@pauleonix
Comment options

Answer selected by 0x5459
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
CUB
Labels
None yet
3 participants