Upload
cecile
View
26
Download
0
Embed Size (px)
DESCRIPTION
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 - PowerPoint PPT Presentation
Citation preview
Telescoping Languages:
A Compiler Strategy for Implementation of High-Level
Domain-Specific Programming Systems
Ken KennedyRice 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
Solution 1:Translate to Low-level
•DeRose/Padua, Int. Conf. Supercomputing,1996
•Use global optimization on low-level code
component library
component library
user libraryuser library
scriptscript
intermediate code
intermediate codetranslatortranslator
global optimizerglobal
optimizer
code generator
code generator
Solution 1:Translate to Low-level
•Problems:—Potentially high compilation times,
even for simple scripts
—Expert knowledge about libraries lost
component library
component library
user libraryuser library
scriptscript
intermediate code
intermediate codetranslatortranslator
global optimizerglobal
optimizer
code generator
code generator
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
Domain Library
Domain Library
Language-Building Compiler
Language-Building Compiler
Script Translator
Script Translator
Enhanced-Language Compiler
Enhanced-Language Compiler
User ScriptUser ScriptOptimized
Object Program
Optimized Object
Program
AnnotationsAnnotations
could run for hours
understands library calls as primitives
Telescoping Languages
AnnotationsAnnotationsLanguage-Building Compiler
Language-Building Compiler
Domain Library
Domain Library
Language-Building Compiler
Language-Building Compiler
Script Translator
Script Translator
Enhanced-Language Compiler
Enhanced-Language Compiler
User ScriptUser ScriptOptimized
Object Program
Optimized Object
Program
AnnotationsAnnotations
Telescoping Languages
•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
Optimization Strategies
Construction of Jump Functions : Example
PROGRAM MAIN V =1 N =0DO WHILE(V>0) V = FUNC(V) N =N +1ENDDOPRINT NEND MAIN
REAL FUNCTION FUNC(X) ! Part of library
IF (X>0) THEN RETURN (X-1)ELSE RETURN XENDIFEND FUNC
! X known > 0inline(X-1)
! X known <= 0inline(X)
! X unknowninline( (X>0 ? X-1 : X) )
PROGRAM MAIN V =1 N =0! DO eliminated V =V -1 N =N +1! ENDDO eliminatedPRINT NEND MAIN
PROGRAM MAIN PRINT 1END MAIN
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
•Discussion : Loss of portability?•Supporting performance portability
—Compute specialized implementations, along with jump functions for each public interface
—Specialize the code for each target machine
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
Thank You