Just-in-time Length Specialization of Dynamic Vector Code

Dynamically typed vector languages are popular in data analytics and statistical computing. In these languages, vectors have both dynamic type and dynamic length, making static generation of efficient machine code difficult. In this paper, we describe a trace-based just-in-time compilation strategy that performs partial length specialization of dynamically typed vector code. This selective specialization is designed to avoid excessive compilation overhead while still enabling the generation of efficient machine code through length-based optimizations such as vector fusion, vector copy elimination, and the use of hardware SIMD units. We have implemented our approach in a virtual machine for a subset of R, a vector-based statistical computing language. In a variety of workloads, containing both scalar and vector code, we show near autovectorized C performance over a large range of vector sizes.

[1]  Jan Vitek,et al.  Evaluating the Design of the R Language - Objects and Functions for Data Analysis , 2012, ECOOP.

[2]  Nagiza F. Samatova,et al.  Transparent runtime parallelization of the R scripting language , 2011, J. Parallel Distributed Comput..

[3]  Jan Vitek,et al.  A fast abstract syntax tree interpreter for R , 2014, VEE '14.

[4]  Pat Hanrahan,et al.  Riposte: A trace-driven compiler and parallel VM for vector code in R , 2012, 2012 21st International Conference on Parallel Architectures and Compilation Techniques (PACT).

[5]  Eric Jones,et al.  SciPy: Open Source Scientific Tools for Python , 2001 .

[6]  Håkan Ardö,et al.  Loop-aware optimizations in PyPy's tracing JIT , 2012, DLS '12.

[7]  David A. Padua,et al.  Optimizing R VM: Allocation Removal and Path Length Reduction via Interpreter-level Specialization , 2014, CGO '14.

[8]  Rolf Dach,et al.  Technical Report 2012 , 2013 .

[9]  Laurie J. Hendren,et al.  Staged Static Techniques to Efficiently Implement Array Copy Semantics in a MATLAB JIT Compiler , 2011, CC.

[10]  Robert Bernecky Shape cliques , 2007, APLQ.

[11]  Carl Friedrich Bolz,et al.  Tracing the meta-level: PyPy's tracing JIT compiler , 2009, ICOOOLPS@ECOOP.

[12]  Kai Trojahner QUBE - Array programming with dependent types , 2012 .

[13]  Vikram S. Adve,et al.  LLVM: a compilation framework for lifelong program analysis & transformation , 2004, International Symposium on Code Generation and Optimization, 2004. CGO 2004..

[14]  Mark N. Wegman,et al.  Efficiently computing static single assignment form and the control dependence graph , 1991, TOPL.

[15]  R Core Team,et al.  R: A language and environment for statistical computing. , 2014 .

[16]  Prithviraj Banerjee,et al.  Static array storage optimization in MATLAB , 2003, PLDI '03.

[17]  Mason Chang,et al.  Trace-based just-in-time type specialization for dynamic languages , 2009, PLDI '09.