Thrust/cudpp 中查找第 k 个最小元素的算法
我正在 Thrust/cudapp 中寻找第 k 个最小元素算法的实现。我用谷歌搜索但似乎没有找到。有谁知道是否存在这样的算法?
我看到有重新排序,但没有说第 k 个最小。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Thrust 目前不提供选择算法(即 STL 中的
std::nth_element
),尽管它在我们的雷达范围内,并且有 有力的证据表明可以在 GPU 上快速完成选择。您现在唯一的办法是使用thrust::sort
或thrust::sort_by_key
(或其stable_
变体)对数据进行排序,然后选择适当的元素。 Thrust 中的基本类型排序(例如int
、float
、char
、double
)是通过非常快的基数实现的对代码进行排序,因此绝对性能仍然相当不错,尽管不如专门的选择方法< /a>.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 withthrust::sort
orthrust::sort_by_key
(or theirstable_
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.