140 likes | 290 Views
Telescoping Languages: A Compiler Strategy for Implementation of High-Level Domain-Specific Programming Systems Ken Kennedy Rice University. Motivation. Background Increasing Complexity of Computer Architectures and Application Structures Difficulty of high-performance programming
E N D
Telescoping Languages: A Compiler Strategy for Implementation of High-Level Domain-Specific Programming Systems Ken Kennedy Rice University
Motivation • Background • Increasing Complexity of Computer Architectures and Application Structures • Difficulty of high-performance programming • Need to allow end-user to develop applications • Use scripting languages like MATLAB, VisualBasic • Problems • Performance limited : Interpreted • Treats Libraries as black boxes • Rewrite in C/C++/FORTRAN for “production” work
component library global optimizer code generator translator intermediate code user library script Solution 1:Translate to Low-level • DeRose/Padua, Int. Conf. Supercomputing,1996 • Use global optimization on low-level code
component library global optimizer code generator translator intermediate code user library script Solution 1:Translate to Low-level • Problems: • Potentially high compilation times, even for simple scripts • Expert knowledge about libraries lost
Telescoping Languages • The Goals • Perform fast local optimization within scripts • Generate efficient code from script quickly • The Solution • Extensively pre-compile and optimize library implementations • Maintain database of precompiled libraries • Use language building compiler to produce enhanced script compiler that supports library calls as language primitives • Can be done in iterations
Enhanced-Language Compiler Optimized Object Program Script Translator User Script Annotations understands library calls as primitives Language-BuildingCompiler Domain Library could run for hours Telescoping Languages
Language-BuildingCompiler Annotations Enhanced-Language Compiler Optimized Object Program Script Translator User Script Annotations Domain Library Language-BuildingCompiler Telescoping Languages
Optimization Strategies • Construction of Jump Functions • Summarize the value of output parameters for a particular procedure in terms of its inputs • Allows instant propagation of parameter properties (type and value) through procedure calls at script compilation time • Library compilation computes Jump Functions for every public interface • Helps inter-procedural analysis • Compositions of JFs need to account for special versions of procedures
Construction of Jump Functions: Example PROGRAM MAIN V =1 N =0 DO WHILE(V>0) V = FUNC(V) N =N +1 ENDDO PRINT N END MAIN REAL FUNCTION FUNC(X) ! Part of library IF (X>0) THEN RETURN (X-1) ELSE RETURN X ENDIF END FUNC PROGRAM MAIN V =1 N =0 ! DO eliminated V =V -1 N =N +1 ! ENDDO eliminated PRINT N END MAIN PROGRAM MAIN PRINT 1 END MAIN ! X known > 0 inline(X-1) ! X known <= 0 inline(X) ! X unknown inline( (X>0 ? X-1 : X) )
Optimization Strategies • Reverse Program Analysis • Identify points of profitable optimization within procedure • Propagate information backward to procedure interface • Can work across inter-library interfaces • Recognition and exploitation of identities • Specify when it is safe to replace composite library calls with efficient specialized code at script compilation time • Example: Replacing a PUSH followed immediately by a POP for calls to a stack library
Implementation • Steps in Script Compilation • Calculate Jump Functions • Analyze propagation of variable properties (value and type) • At each invocation point for libraries, select most specialized code given the variable properties • Substitute the selected code inline • Supporting performance portability • Compute specialized implementations, along with jump functions for each public interface • Specialize the code for each target machine • Discussion : Loss of portability?
Advantages • Reliability • Script compiler can validate parameters • Libraries can specify correctness conditions • Client-Server communications • Optimize application along with interface specific part of code • Perform strength reductions for remote calls • Protection of Source Code • Allows library developer to prohibit inlining of specific portions of code
Discussions • Dealing with variation in application data structures • Solution: Trade code space for configurability? • Select from alternative implementations at run time • Scope for more optimizations • Further work : Chauhan & Kennedy, “Optimizing Strategies for Telescoping Languages: Procedure Strength Reduction and Procedure Vectorization”, Proceedings of the 15th ACM International Conference on Supercomputing, June 16-21, 2001 • Comparison with alternative approaches