- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我要求一个 c++ 库来执行 GPU 加速排序(大约 1GB 的数据)和合并排序(例如,大约 100GB 的数据——但大小无关紧要,因为合并是一种流算法)。许可证必须是 LGPL、BSD 或类似的。由于可移植性,我非常喜欢 OpenCL(但我也对 CUDA 库的链接感兴趣)。我很欣赏有关此主题的论文和博客文章的链接。
1GB(即128 000 000个8字节实体)的2-way merge sort会消耗大约log2(128 000 000)·1G = 27GB内存带宽,即在 顺序 内存带宽约为 30GB/s 的现代 CPU 上大约需要 1 秒。 (任何非合并排序似乎都需要更长的时间,因为非顺序内存访问要慢 10-100 倍)。
虽然我不熟悉现代 GPU,但我怀疑 1GB 的合并排序将花费 0.2 秒甚至更少,因为典型的 GPU 内存带宽约为 150GB/s,如 AMD/ATI 58xx(参见,例如 http://en.wikipedia.org/wiki/Comparison_of_AMD_graphics_processing_units#Evergreen_.28HD_5xxx.29_series)
这至少是 5 倍的加速。 (通过 16x PCI-E 2.0 传输 1GB 的时间约为 0.125 秒,但似乎可以在排序的同时进行 PCI 传输;但是,这可能需要 2GB 或 3GB 的视频卡内存,而不是 1GB)。
我怀疑由于适用于 GPU 的多于 2 路合并排序或某种排序,速度会更快。
最佳答案
你看过Thrust了吗? ?
来自项目页面:
Thrust is a parallel algorithms library which resembles the C++ Standard Template Library (STL). Thrust's high-level interface greatly enhances developer productivity while enabling performance portability between GPUs and multicore CPUs. Interoperability with established technologies (such as CUDA, TBB and OpenMP) facilitates integration with existing software. Develop high-performance applications rapidly with Thrust!
许可证是 Apache,所以它应该适合你。
关于c++ - GPU 加速排序 (~1GB) 和归并排序 (~100GB),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14593791/
本文实例汇总了Java各种排序算法。分享给大家供大家参考,具体如下: 1. 冒泡排序: ?
1.冒泡排序 它重复地走访过要排序的元素列,依次比较两个相邻的元素,如果顺序错误就把他们交换过来。走访元素的工作是重复地进行直到没有相邻元素需要交换,也就是说该元素列已经排序完成。 算法步
前言 平时用惯了高级语言高级工具高级算法,难免对一些基础算法感到生疏。但最基础的排序算法中实则蕴含着相当丰富的优化思维,熟练运用可起到举一反三之功效。 选择排序 选择排序几乎是
我是一名优秀的程序员,十分优秀!