130 likes | 281 Views
A Complete Compilation System. Conventional Approach. Input Source. Intermediate Code. Output Assembly. Compiler Frontend analysis & optimization. Compiler Backend analysis & optimization. Frontends Parafrase-2 Polaris PFA …. Backends MIPSPro FORTRAN Visual C++ GCC.
E N D
Conventional Approach Input Source Intermediate Code Output Assembly Compiler Frontend analysis & optimization Compiler Backend analysis & optimization • Frontends • Parafrase-2 • Polaris • PFA • … • Backends • MIPSPro FORTRAN • Visual C++ • GCC • ... Lose Analysis Information!
The PROMIS Approach • LUIR lowering • Simplify to 3-addr code • In-place to maintain analysis • Opcode tagging • Tag stmts w/ possible opcodes • In place to maintain analysis HUIR LUIR IUIR SS F77 EPIC Analysis Data, Control, Cost Symbolic, etc. Standard Opt. Strength Reduct., CSE, CP, etc. Machine Specific Optimizations C SMT Transformations Distribution, Fusion, Interchange, Unroll, etc. C++ Resource Allocation ILP Opt. … NUMA Java NOW Instruction Scheduling/ Packing Parallelization Loop and Functional . . . Machine Indep. Peephole Opt. . . UMD
The PROMIS HTG • Acyclic Task Graph (at its core) • Single statement nodes • CFE, DDE, CDE • Hierarchical Blocks • Loops become SESE compound nodes • HtgBBlock - may contain compound nodes • Hierarchical Edges • Don’t cross levels of hierarchy • Edges with higher levels source/sink into fake start/stop nodes • Edges with lower levels source/sink into compound nodes
Block Start Start HtgBBlock CDE Branch DDE Stop HtgBBlock HtgBBlock CFE Start HtgBBlock Loop Stop Stop
Loop Start HtgBBlock Start a[i] = b + c i-assign Branch p-add i-mult Stop v-addr i-var i-var i-var Stop a i b c
Retargeting PROMIS -- UMD • All high and many low level optimizations and analyses operate on machine independent internal representation • All machine specific information contained within the UMD description • Code Generator and optimization parameters are retargeted simply by changing the UMD description
.c .cpp PE PE M M PE PE PE PE M M M M Retargetable & Reconfigurable Source files MD files Target VLIW MD PE Vector Unit ??? Multi- proc Multi- threaded Register Allocator NOW Thread Unit Instruction Scheduler
Information Provided by the UMD • High Level • Types of parallelism available: multiprocessor, multithreading, vector units, etc. • Intrinsic function mappings • Intermediate Level • Intrinsic function lowering • Low Level • Opcode mapping, Instruction Formats, etc. • Resource usage, pipelines, latencies, etc.
Saving the PROMISInternal Representation • Can easily save and restore a program’s Internal Representation to a file • Avoid re-executing the same passes on the same programs by saving intermediate results at the desired location • More Comprehensive, less Destructive, and much Faster than generating C code • NO analysis information is recomputed!
Common Uses:Repeated Experiments, Debugging • Setup: Run initial passes and dump to file • Setup: Run initial passes and dump to file • Use: Load from file and run experiment Run first N-1 Passes .PIR File Unload .PIR File Run experiment on (or debug) Pass N No need to repeat First N-1passes Load
Potential Uses • Interface to connect PROMIS to other compilers, such as a back-end optimizer • This interface is more expressive than dumping source code (e.g. can represent Data Dependence Analysis)
Main Issues • Each class in the Internal Representation must implement Unload and Load functions • Basic data types are written by value • Objects are serialized and tokenized before being written to file