arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2503.05934cs.DScs.CC
收藏

通过利用Alphadev的排序网络作为基础情况来提高归并排序和快速排序的性能

Improving Merge Sort and Quick Sort Performance by Utilizing Alphadev's Sorting Networks as Base Cases

Stetson University(斯特森大学)

Anas Gamal Aly, Anders E. Jensen, Hala ElAarag

AI总结:

本文研究将Google DeepMind优化的排序网络作为归并排序和快速排序的基础情况,以提升小数组排序效率,结果显示优化后的归并排序在随机和近排序数组上速度提升达1.5倍,排序数组达2倍,且在大规模数组中超越传统快速排序。

摘要:

近期,Google DeepMind引入了针对小固定大小数组(3-8)优化的排序网络,以实现更快的性能。本研究探讨将这些网络作为经典分治排序算法(归并排序和快速排序)的基础情况进行整合,以利用这些高效的排序网络来处理递归过程中生成的小子数组。我们对11种不同的优化配置进行了基准测试,并将其与传统归并排序和快速排序进行了比较。我们测试了这些配置在随机、已排序和近似已排序数组上的表现。我们的优化归并排序使用三种排序网络(大小6、7和8)的配置,在随机和近排序数组上相比传统归并排序至少提升了1.5倍的速度,在已排序数组上至少提升了2倍。这种优化的归并排序在排序大小为10,000及更大的随机数组时,超过了传统快速排序和同样优化的快速排序变体。当将我们的优化快速排序与传统快速排序进行比较时,我们发现使用3到5的配置在10,000大小的已排序数组上实现了1.5倍的速度提升。6到8的配置在25,000到100万元素的已排序数组上保持了一致的1.5倍改进。我们的发现展示了将AI优化的排序网络整合到传统排序算法中以提高性能的潜力。

英文摘要:

Recent work by Google DeepMind introduced assembly-optimized sorting networks that achieve faster performance for small fixed-size arrays (3-8). In this research, we investigate the integration of these networks as base cases in classical divide-and-conquer sorting algorithms, specifically Merge Sort and Quick Sort, to leverage these efficient sorting networks for small subarrays generated during the recursive process. We conducted benchmarks with 11 different optimization configurations and compared them to classical Merge Sort and Quick Sort. We tested the configurations with random, sorted and nearly sorted arrays. Our optimized Merge Sort, using a configuration of three sorting networks (sizes 6, 7, and 8), achieves at least 1.5x speedup for random and nearly sorted arrays, and at least 2x speedup for sorted arrays, in comparison to classical Merge Sort. This optimized Merge Sort surpasses both classical Quick Sort and similarly optimized Quick Sort variants when sorting random arrays of size 10,000 and larger. When comparing our optimized Quick Sort to classical Quick Sort, we observe a 1.5x speedup using the 3-to-5 configuration on sorted arrays of size 10,000. The 6-to-8 configuration maintains a consistent 1.5x improvement across sorted arrays from 25,000 to 1 million elements. Our findings demonstrate the potential of integrating AI-optimized sorting networks to enhance the performance of classical sorting algorithms.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑