An experimental study of sorting and branch prediction

Author:

Biggar Paul1,Nash Nicholas1,Williams Kevin1,Gregg David1

Affiliation:

1. Trinity College Dublin, Ireland

Abstract

Sorting is one of the most important and well-studied problems in computer science. Many good algorithms are known which offer various trade-offs in efficiency, simplicity, memory use, and other factors. However, these algorithms do not take into account features of modern computer architectures that significantly influence performance. Caches and branch predictors are two such features and, while there has been a significant amount of research into the cache performance of general purpose sorting algorithms, there has been little research on their branch prediction properties. In this paper, we empirically examine the behavior of the branches in all the most common sorting algorithms. We also consider the interaction of cache optimization on the predictability of the branches in these algorithms. We find insertion sort to have the fewest branch mispredictions of any comparison-based sorting algorithm, that bubble and shaker sort operate in a fashion that makes their branches highly unpredictable, that the unpredictability of shellsort's branches improves its caching behavior, and that several cache optimizations have little effect on mergesort's branch mispredictions. We find also that optimizations to quicksort, for example the choice of pivot, have a strong influence on the predictability of its branches. We point out a simple way of removing branch instructions from a classic heapsort implementation and also show that unrolling a loop in a cache-optimized heapsort implementation improves the predicitability of its branches. Finally, we note that when sorting random data two-level adaptive branch predictors are usually no better than simpler bimodal predictors. This is despite the fact that two-level adaptive predictors are almost always superior to bimodal predictors, in general.

Publisher

Association for Computing Machinery (ACM)

Subject

Theoretical Computer Science

Reference38 articles.

1. A super scalar sort algorithm for RISC processors

2. The input/output complexity of sorting and related problems

3. Austin T. Ernst D. Larson E. Weaver C. Raj Desikan R. N. Huh J. Yoder B. Burger D. and Keckler S. 2001. SimpleScalar Tutorial (for release 4.0). Austin T. Ernst D. Larson E. Weaver C. Raj Desikan R. N. Huh J. Yoder B. Burger D. and Keckler S. 2001. SimpleScalar Tutorial (for release 4.0).

4. Engineering a sort function

Cited by 5 articles. 订阅此论文施引文献 订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献

1. BlockQuicksort;ACM Journal of Experimental Algorithmics;2019-12-17

2. Ternary-Decimal Exclusion Algorithm for Multiattribute Utility Functions;Lecture Notes in Computer Science;2019

3. When Merging and Branch Predictors Collide;2014 4th Workshop on Irregular Applications: Architectures and Algorithms (IA^3);2014-11-16

4. Branch Mispredictions Don’t Affect Mergesort;Experimental Algorithms;2012

5. Lean Programs, Branch Mispredictions, and Sorting;Lecture Notes in Computer Science;2012

同舟云学术

1.学者识别学者识别

2.学术分析学术分析

3.人才评估人才评估

"同舟云学术"是以全球学者为主线,采集、加工和组织学术论文而形成的新型学术文献查询和分析系统,可以对全球学者进行文献检索和人才价值评估。用户可以通过关注某些学科领域的顶尖人物而持续追踪该领域的学科进展和研究前沿。经过近期的数据扩容,当前同舟云学术共收录了国内外主流学术期刊6万余种,收集的期刊论文及会议论文总量共计约1.5亿篇,并以每天添加12000余篇中外论文的速度递增。我们也可以为用户提供个性化、定制化的学者数据。欢迎来电咨询!咨询电话:010-8811{复制后删除}0370

www.globalauthorid.com

TOP

Copyright © 2019-2024 北京同舟云网络信息技术有限公司
京公网安备11010802033243号  京ICP备18003416号-3