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