Staged Static Techniques to Efficiently Implement Array Copy Semantics in a MATLAB JIT Compiler

Matlab has gained widespread acceptance among scientists. Several dynamic aspects of the language contribute to its appeal, but also provide many challenges. One such problem is caused by the copy semantics of Matlab. Existing Matlab systems rely on reference-counting schemes to create copies only when a shared array representation is updated. This reduces array copies, but requires runtime checks. We present a staged static analysis approach to determine when copies are not required. The first stage uses two simple, intraprocedural analyses, while the second stage combines a forward necessary copy analysis with a backward copy placement analysis. Our approach eliminates unneeded array copies without requiring reference counting or frequent runtime checks. We have implemented our approach in the McVM JIT. Our results demonstrate that, for our benchmark set, there are significant overheads for both existing reference-counted and naive copy-insertion approaches, and that our staged approach is effective in avoiding unnecessary copies.

[1]  Torbjörn Ekman,et al.  The jastadd extensible java compiler , 2007, OOPSLA.

[2]  Yuefan Deng,et al.  New trends in high performance computing , 2001, Parallel Computing.

[3]  Paul Hudak,et al.  The aggregate update problem in functional programming systems , 1985, POPL.

[4]  Laurie J. Hendren,et al.  AspectMatlab: an aspect-oriented scientific programming language , 2010, AOSD.

[5]  Jim Weigang An introduction to STSC's APL compiler , 1985, APL '85.

[6]  Steven S. Muchnick,et al.  Advanced Compiler Design and Implementation , 1997 .

[7]  Jack Dongarra,et al.  LAPACK Users' Guide, 3rd ed. , 1999 .

[8]  James Demmel,et al.  LAPACK Users' Guide, Third Edition , 1999, Software, Environments and Tools.

[9]  Cleve B. Moler,et al.  Numerical computing with MATLAB , 2004 .

[10]  A. V. S. Sastry Efficient array update analysis of strict functional languages , 1994 .

[11]  David A. Padua,et al.  FALCON: A MATLAB Interactive Restructuring Compiler , 1995, LCPC.

[12]  Matemática,et al.  Society for Industrial and Applied Mathematics , 2010 .

[13]  Jack J. Dongarra,et al.  Automated empirical optimizations of software and the ATLAS project , 2001, Parallel Comput..

[14]  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..

[15]  Michael Spertus,et al.  Transparent Programmer-Directed Garbage Collection for C++ , 2007 .

[16]  Mitchell Wand,et al.  Set constraints for destructive array update optimization , 1998, Proceedings of the 1998 International Conference on Computer Languages (Cat. No.98CB36225).

[17]  Edmond Schonberg,et al.  Programming with Sets: An Introduction to SETL , 1986 .

[18]  William H. Press,et al.  Numerical recipes in C. The art of scientific computing , 1987 .

[19]  K. Gopinath,et al.  Copy elimination in functional languages , 1989, POPL '89.

[20]  Jun Li,et al.  MCFOR: A MATLAB TO FORTRAN 95 COMPILER , 2010 .

[21]  William H. Press,et al.  Numerical Recipes: The Art of Scientific Computing , 1987 .

[22]  Kenneth E. Iverson,et al.  A programming language , 1899, AIEE-IRE '62 (Spring).

[23]  Martin Odersky,et al.  How to make destructive updates less destructive , 1991, POPL '91.

[24]  Mitchell Wand,et al.  The Higher-Order Aggregate Update Problem , 2009, VMCAI.

[25]  Laurie J. Hendren,et al.  MetaLexer: a modular lexical specification language , 2011, AOSD '11.

[26]  Maxime Chevalier-Boisvert MCVM: AN OPTIMIZING VIRTUAL MACHINE FOR THE MATLAB PROGRAMMING LANGUAGE , 2009 .

[27]  Edith Schonberg,et al.  Programming with Sets , 1986, Texts and Monographs in Computer Science.

[28]  Deepak Goyal,et al.  A New Solution to the Hidden Copy Problem , 1998, SAS.

[29]  Laurie J. Hendren,et al.  Optimizing Matlab through Just-In-Time Specialization , 2010, CC.

[30]  W. Press,et al.  Numerical Recipes: The Art of Scientific Computing , 1987 .

[31]  P. Hanrahan,et al.  Sequoia: Programming the Memory Hierarchy , 2006, ACM/IEEE SC 2006 Conference (SC'06).

[32]  Natarajan Shankar,et al.  Static Analysis for Safe Destructive Updates in a Functional Language , 2001, LOPSTR.