I am looking for an implemention of kth smallest element algorithm in thrust/cudapp. I Googled for it but dont seem to find it. Does any one know if there exists such an algorithm?
I saw that there is reordering but it does not say kth smallest.
I am looking for an implemention of kth smallest element algorithm in thrust/cudapp. I Googled for it but dont seem to find it. Does any one know if there exists such an algorithm?
I saw that there is reordering but it does not say kth smallest.
Thrust does not currently provide the selection algorithm (i.e. std::nth_element
in the STL) though it's on our radar and there's good evidence that selection can be done quickly on the GPU. Your only recourse right now is to sort the data with thrust::sort
or thrust::sort_by_key
(or their stable_
variants) and then pick the appropriate element(s). Sorting primitive types (e.g. int
, float
, char
, double
) in Thrust is implemented with a very fast radix sort code, so the absolute performance will still be quite good, albeit not as efficient as a specialized selection method.