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.
翻译:谷歌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优化排序网络对提升经典排序算法性能具有显著潜力。