Title
Optimizing data structures in high-level programs: new directions for extensible compilers based on staging
Abstract
High level data structures are a cornerstone of modern programming and at the same time stand in the way of compiler optimizations. In order to reason about user- or library-defined data structures compilers need to be extensible. Common mechanisms to extend compilers fall into two categories. Frontend macros, staging or partial evaluation systems can be used to programmatically remove abstraction and specialize programs before they enter the compiler. Alternatively, some compilers allow extending the internal workings by adding new transformation passes at different points in the compile chain or adding new intermediate representation (IR) types. None of these mechanisms alone is sufficient to handle the challenges posed by high level data structures. This paper shows a novel way to combine them to yield benefits that are greater than the sum of the parts. Instead of using staging merely as a front end, we implement internal compiler passes using staging as well. These internal passes delegate back to program execution to construct the transformed IR. Staging is known to simplify program generation, and in the same way it can simplify program transformation. Defining a transformation as a staged IR interpreter is simpler than implementing a low-level IR to IR transformer. With custom IR nodes, many optimizations that are expressed as rewritings from IR nodes to staged program fragments can be combined into a single pass, mitigating phase ordering problems. Speculative rewriting can preserve optimistic assumptions around loops. We demonstrate several powerful program optimizations using this architecture that are particularly geared towards data structures: a novel loop fusion and deforestation algorithm, array of struct to struct of array conversion, object flattening and code generation for heterogeneous parallel devices. We validate our approach using several non trivial case studies that exhibit order of magnitude speedups in experiments.
Year
DOI
Venue
2013
10.1145/2429069.2429128
POPL
Keywords
Field
DocType
powerful program,high-level program,optimizing data structure,extensible compiler,custom ir node,ir node,low-level ir,high level data structure,new direction,ir transformer,program fragment,ir interpreter,program execution,program generation,code generation,data structures,languages,performance,staging,design
Front and back ends,Loop fusion,Data structure,Programming language,Program transformation,Computer science,Partial evaluation,Parallel computing,Code generation,Compiler,Optimizing compiler
Conference
Volume
Issue
ISSN
48
1
0362-1340
Citations 
PageRank 
References 
50
1.42
34
Authors
9
Name
Order
Citations
PageRank
Tiark Rompf174345.86
Arvind K. Sujeeth250220.58
Nada Amin316611.47
Kevin J. Brown444818.62
Vojin Jovanovic51035.03
HyoukJoong Lee641417.71
Manohar Jonnalagedda7894.96
Kunle Olukotun84532373.50
Martin Odersky92261170.39