Thrust/cudpp 中查找第 k 个最小元素的算法

发布于 2024-12-22 20:31:07 字数 101 浏览 3 评论 0原文

我正在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空名 2024-12-29 20:31:07

Thrust 目前不提供选择算法(即 STL 中的 std::nth_element),尽管它在我们的雷达范围内,并且有 有力的证据表明可以在 GPU 上快速完成选择。您现在唯一的办法是使用 thrust::sortthrust::sort_by_key (或其 stable_ 变体)对数据进行排序,然后选择适当的元素。 Thrust 中的基本类型排序(例如 intfloatchardouble)是通过非常快的基数实现的对代码进行排序,因此绝对性能仍然相当不错,尽管不如专门的选择方法< /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 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文