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

应用排序网络综合优化排序库

Applying Sorting Networks to Synthesize Optimized Sorting Libraries

Michael Codish, Luís Cruz-Filipe, Markus Nebel, Peter Schneider-Kamp

摘要:

本文展示了排序网络理论的应用,以促进优化的通用排序库的合成。标准排序库通常基于经典的快速排序算法与插入排序的组合,插入排序作为小的固定数量输入的基本情况。通过忽略循环条件展开基本情况的代码消除了分支,并导致代码等效于排序网络。这使得基于排序网络优化的进一步程序转换的应用成为可能,并最终从排序网络合成代码。我们表明,如果考虑比较和交换的数量,那么理论预测这种方法没有真正的优势。然而,当利用指令级并行和非分支条件赋值指令时,获得了显著的加速,这两者在现代CPU架构中是常见的。我们提供的经验证据表明,使用代码合成从高效的排序网络作为快速排序库的基本情况下,在现实世界中显着的速度提升。

英文摘要:

This paper shows an application of the theory of sorting networks to facilitate the synthesis of optimized general purpose sorting libraries. Standard sorting libraries are often based on combinations of the classic Quicksort algorithm with insertion sort applied as the base case for small fixed numbers of inputs. Unrolling the code for the base case by ignoring loop conditions eliminates branching and results in code which is equivalent to a sorting network. This enables the application of further program transformations based on sorting network optimizations, and eventually the synthesis of code from sorting networks. We show that if considering the number of comparisons and swaps then theory predicts no real advantage of this approach. However, significant speed-ups are obtained when taking advantage of instruction level parallelism and non-branching conditional assignment instructions, both of which are common in modern CPU architectures. We provide empirical evidence that using code synthesized from efficient sorting networks as the base case for Quicksort libraries results in significant real-world speed-ups.

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

↑