Static Type Inference for Specialization in a Telescoping Compiler

The telescoping languages approach achieves high performance from applications encoded as high-level scripts. The core idea is to pre-compile underlying libraries to generate multiple variants optimized for use in different possible contexts including different argument types. This paper proposes a type inference algorithm that enables this kind of specialization. The algorithm infers types over untyped library procedures before actual inputs are known. For our matlab compiler, the notion of type captures matrix properties such as size, sparsity pattern, and data type. Type inference is necessary both to determine the minimum number of variants needed to handle all possible uses of the library procedure as well as to statically determine, for each variant, which optimized implementations should be dispatched at each call location. A key contribution that arose from this work is a notion of mutually exclusive types. To illustrate these types, we formalize the underlying type system, constraint-collection, and solution. Finally, we prove that the algorithm is polynomial under practical conditions.

[1]  Pascal Van Hentenryck,et al.  The Constraint Logic Programming Language CHIP , 1988, FGCS.

[2]  P. Sallé Une extension de la theorie des types en λ-calcul , 1978 .

[3]  Simon J. Cox,et al.  Partial Evaluation of MATLAB , 2003, GPCE.

[4]  Michael J. Maher,et al.  Constraint Logic Programming: A Survey , 1994, J. Log. Program..

[5]  Robin Milner,et al.  A Theory of Type Polymorphism in Programming , 1978, J. Comput. Syst. Sci..

[6]  Luca Cardelli,et al.  A Semantics of Multiple Inheritance , 1984, Information and Computation.

[7]  Joxan Jaffar,et al.  Constraint logic programming , 1987, POPL '87.

[8]  Ken Kennedy,et al.  Automatic Type-Driven Library Generation for Telescoping Languages , 2003, ACM/IEEE SC 2003 Conference (SC'03).

[9]  Jack J. Dongarra,et al.  Automatically Tuned Linear Algebra Software , 1998, Proceedings of the IEEE/ACM SC98 Conference.

[10]  Guy L. Steele,et al.  The definition and implementation of a computer programming language based on constraints , 1980 .

[11]  Joachim Schimpf,et al.  ECLiPSe: A Platform for Constraint Logic Programming , 1997 .

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

[13]  Prithviraj Banerjee,et al.  Implementing an array shape inference system for matlab using mathematica , 2002 .

[14]  Alain Colmerauer,et al.  An introduction to Prolog III , 1989, CACM.

[15]  Steven G. Johnson,et al.  FFTW: an adaptive software architecture for the FFT , 1998, Proceedings of the 1998 IEEE International Conference on Acoustics, Speech and Signal Processing, ICASSP '98 (Cat. No.98CH36181).

[16]  Ken Kennedy,et al.  Interprocedural side-effect analysis in linear time , 1988, PLDI '88.

[17]  David A. Padua,et al.  MaJIC: compiling MATLAB for speed and responsiveness , 2002, PLDI '02.

[18]  John C. Reynolds,et al.  Using category theory to design implicit conversions and generic operators , 1980, Semantics-Directed Compiler Generation.

[19]  Ken Kennedy,et al.  Telescoping Languages: A Strategy for Automatic Generation of Scientific Problem-Solving Systems from Annotated Libraries , 2001, J. Parallel Distributed Comput..

[20]  David A. Padua,et al.  Techniques for the translation of MATLAB programs into Fortran 90 , 1999, TOPL.

[21]  John C. Reynolds,et al.  Design of the programming language FORSYTHE , 1997 .

[22]  David A. Padua,et al.  MaJIC: A Matlab Just-In-time Compiler , 2000, LCPC.

[23]  B. Pierce Programming with intersection types and bounded polymorphism , 1992 .

[24]  Roland H. C. Yap,et al.  The CLP( R ) language and system , 1992, TOPL.

[25]  Linda Torczon,et al.  Interprocedural constant propagation: a study of jump function implementation , 1993, PLDI '93.

[26]  John C. Mitchell,et al.  Type inference with simple subtypes , 1991, Journal of Functional Programming.

[27]  Luiz A. DeRose,et al.  Compiler techniques for MATLAB programs , 1996 .

[28]  Frank Pfenning,et al.  Eliminating array bound checking through dependent types , 1998, PLDI.

[29]  Calvin Lin,et al.  An annotation language for optimizing software libraries , 1999, DSL '99.