1 / 31

An Overview of the SUIF2 System

An Overview of the SUIF2 System. Monica Lam Stanford University http://suif.stanford.edu/. Stanford University Monica Lam Gerald Aigner Gerald Cheong Amer Diwan David Heine Amy Lim Vladimir Livshits Virendra Mehta Brian Murphy Costa Sapuntzakis Hansel Wan Chris Wilson. Harvard

andrewp
Download Presentation

An Overview of the SUIF2 System

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. An Overview of the SUIF2 System Monica Lam Stanford University http://suif.stanford.edu/

  2. Stanford University Monica Lam Gerald Aigner Gerald Cheong Amer Diwan David Heine Amy Lim Vladimir Livshits Virendra Mehta Brian Murphy Costa Sapuntzakis Hansel Wan Chris Wilson Harvard Michael Smith Erven Rohou Glenn Holloway Gang Chen Eric Feigin Nick Gloy Stuart Schechter Jason Simmons Omri Traub Cliff Young Team Members UCSB • Urs Hoelzle • Andrew Duncan • Bogdan Cocosel • Holger Kienle • Kristian Kvilekval • Kevin O’gorman • Prashanth Ramdas • Radu Rugina • Andrew Rutz Portland Group • David Moore • Vince Shuster • Deb Caruso • David Wohlford • Bob Scollard

  3. The SUIF System PGI Fortran EDG C++ Java Interprocedural Analysis Parallelization Locality Opt Inst. Scheduling Register Allocation SUIF2 C Alpha x86

  4. Overview of SUIF Components Basic Infrastructure Extensible IR and utilities Modular compiler system Pass submodule PGI Fortran, EDG C/C++, Java FE Standard IR, OSUIF (for OO lang) Hoof: Suif object specification language SUIF1 / SUIF2 translators Statement dismantlers Suifbrowser Backend Infrastructure Optimization framework Register allocation Scheduling Alpha and x86 backends HL Analysis Infrastructure Graphs, sccs Presburger arithmetic (omega) Farkas lemma&“Gaussian Elimination” Interprocedural framework Garbage collection (Boehm’s) Call graph Affine partitioning for parallelism & locality Steensgaard’s alias analysis Interprocedural parallelization: array/scalar dependence/privatization

  5. Suif1 design A fixed set of flat C++ classes All codes must change if we add new IR nodes e.g. printing objects, reading and writing to file Higher level semantic objects OSUIF (for object-oriented programming) Verilog event-driven control flow semantics Saturated arithmetic used in multimedia instruction sets Program analysis concepts phi nodes in SSA analysis synchronization operations introduced by parallelization Results of analysis Motivation for Extensible IR

  6. Metaclass: captures representation of IR nodes in a data structure Enables common generic routines to implement Persistence: reading/writing to disk Cloning: routine that copies the data structure Printing: a generic routine to print out the information Walkers, iterators, visitors Concept I: Reflective IR

  7. ExecutionObject Statement get_child_statements IfStatement WhileStatement get_then_part get_else_part get_body Concept II:Object hierarchy & virtual aggregate fields • Abstract names to refer to fundamental concepts in subclasses • e.g. get_child_statements • IfStatement: get_then_part and get_else_part, or • WhileStatement: get_body

  8. Object hierarchy & virtual aggregate fields • Maximize reuse and modular code development • Write code that operates at the highest level of abstraction • A pass works, without recompilation, for code with new subclasses if new refinements are immaterial to a pass. • The unknown information is maintained across a pass • Example: • Reuse an intraprocedural dead code elimination written for SUIF on OSUIF (object-oriented SUIF) code

  9. Multiple representations for different semantic levels e.g. FOR loops versus basic blocks in a control flow graph => Alternative representations Mixture of high-level and low-level constructs Dismantlers lower the representation Concept III: Multiple Representations for High-Level Analyses

  10. Concept IV: High-level object specification Insulates user from details Object Definition (.hoof) SUIF Macro Generator a general grammar-based tool Meta-Class System reading & writing to file in machine-independent format Interface for user (.h) Implementation in Meta-Class System (.cpp) • Easy for the programmer • Easy for the implementor to develop the system

  11. Uniform data access functions (get_ & set_) Automatic generation of meta class information etc. Example of a Hoof Definition C++ • class New : public SuifObject • { • public: • int get_x(); • void set_x(int the_value); • ~New(); • void print(…); • static const Lstring get_class_name(); • … • } hoof • concrete New • { int x; }

  12. abstract Statement : ExecutionObject { virtual list<Statement* owner> child_statements; ... } concrete IfStatement : Statement { Expression * condition in source_ops; Statement * owner then_part in child_statements; Statement * owner else_part in child_statements; } Examples of Suif Nodes

  13. SUIF1: All passes read and write suif files: more modular and supportive of experimentation but it is slow Data between passes are written out as annotations Annotations must be expressed as strings when written out Requires manual pickling of annotations Nontrivial effort to support any interactivity Motivation for a Modular Compiler System

  14. Executable suifdriver Passes IR suifnodes analyses optimizations basicnodes Kernel suifkernel iokernel SUIF2Concept I: A Modular Compiler Architecture MODULES:

  15. Components • Kernel: provides all basic functionality • iokernel: implements I/O • suifkernel: hides iokernel and provides modules support, cloning, command line parsing, list of factories, etc. • Modules • passes: provides a pass framework • IR: basic program representations • Suifdriver • provides execution control over modules and passes

  16. Memory/Memory vs File/File Passes COMPILER A driver that imports & applies modules to program in memory A series of stand-alone programs Suif-file1 Suif-file1 driver+module1 Suif-file2 Suifdriver imports/executes module1 module2 module3 driver+module2 Suif-file3 driver+module3 Suif-file4 Suif-file4

  17. Concept II: Dynamic Registration of Modules • Compilation State: SuifEnv • Keeps the loaded SUIF program • All the registered modules • A module is a C++ class • that implements either a pass or a set of nodes in IR • must have a unique module_name • one or more modules make up a dll (dynamically linked library) • each library includes a function (init_<dllname>) to register the module dynamically

  18. > suifdriver suif> import basicnodes suifnodes suif> import mylibrary suif> load test.suif suif> mylibrary_pass1 suif> print test.out suif> save test.tsuif The Suifdriver: accepts a simple scripting language. (A version that accepts tcl/tk also exists). pre-registered modules (import, load, print, save) imports libraries dynamically which can register new modules (new commands) System can easily be used for demand-driven program analysis e.g. SUIF explorer or a debugger Dynamic Assembly of a Compiler

  19. Concept III: Easy to write a new analysis: subclass of a pass module Executable suifdriver Passes IR suifnodes analyses optimizations basicnodes Kernel suifkernel iokernel

  20. class mypass: public Pass { public: mypass(SuifEnv *env, const Lstring &name): Pass(env, name) {} virtual ~mypass() {} Module *clone() const {return(Module*) this:} void do_procedure_definition (ProcedureDefinition* proc_def) { cout << proc_def->get_procedure_symbol() ->get_name() cout << object_iterator<ExecutionObject>(proc_def).length(); } } extern “C” void init_mypass (SuifEnv *suif_env) { suif_env->get_module_subsystem()->register_module (new mypass (suif_env, “mypass”)); } Example Pass: Count Statements in Procedures

  21. I. Compose compiler with existing passes Dynamic composition of different passes II. Develop new passes User concentrates on algorithmic issues Infrastructure provides common functionalities Write code once, can run on SUIF program in memory or a file III. Develop new IR High-level specification of the IR nodes Old code works with new IR without recompilation Research Infrastructure: Support at 3 Levels

  22. Deliverables • Infrastructure: basesuif system • Components: Front ends and passes • Testing • Documentation

  23. Basic Infrastructure (Beta release) • SUIF object system • I/O, printing, cloning • Visitors: dispatch method according to type • Iterators: simple iteration of certain objects • Walkers: user-controllable traversal of data structures • Module subsystem • Hoof language implementation • Standard IR representation • General data structures • Infinite precision integers, strings • lists, sets, hash maps • assertion, error handling, command line parsing • SuifBrowser • Presents the source and SUIF code

  24. Compiler components: C • EDG C front end -> SUIF • Created cfenodes to represent C constructs, which are then lowered • SUIF -> C • SUIF1 -> SUIF -> SUIF1 • Enables SUIF1 users to use old SUIF1 passes in the compiler • Testing • PGI unit tests • 16 errors out of > 3000 tests • Spec95int: all but gcc work. (gcc not Ansi C, we are working on it). EDG C lcc C SUIF + cfenodes SUIF1 SUIF C SUIF1

  25. Object-oriented Languages: C++ and Java • OSUIF: object-extension of SUIF (for Java and C++) • Types: classes, methods and fields • Symbols: fields & methods • SymbolTable: class-specific behavior for member lookup • Statements: exception handling & object-oriented instructions • EDG C++ -> SUIF (on track) j2s EDG C++ OSUIF SUIF C

  26. Java • no threads, exception handling, dynamic loading • Java byte code-> OSUIF (Solaris) • Class loading, resolution of the constant pool • Control flow analysis (normal and exception handling) • Data flow analysis (construct type information) • OSUIF code generation • OSUIF -> SUIF • build-vtables: virtual tables • lower-instance-variables: layout of class-types • lower-methods: method dispatch • lower-static-fields, lower-static-methods: put static in global scope • Testing: compiled JDK 1.2beta2 javac compiler: 538 Java classes

  27. Fortran front end • Based on PGI’s proprietary front end • PGI Fortran includes F90 and HPF; only the F77 subset is translated to SUIF • To be released only in binary form • Alpha version delivered to Stanford, not yet released

  28. Documentation • The SUIF2 Infrastructure Guide (an index to all documentation) • Overview of the SUIF Infrastructure • The SUIF Representation Guide • The Basic SUIF Programmer’s Guide • The SUIF System Programmer’s Reference Manual • All the high-level interfaces documented (example) • Generated from the .h files by Doxygen • All the cross references, e.g. class hierarchy information • Web page: http://suif.stanford.edu/

  29. The End

  30. Released Overview of SUIF Components Basic Infrastructure Extensible IR and utilities Modular compiler system Pass submodule PGI Fortran, EDG C/C++, Java FE Standard IR, OSUIF (for OO lang) Hoof: Suif object specification language SUIF1 / SUIF2 translators Statement dismantlers Suifbrowser Backend Infrastructure Optimization framework Register allocation Scheduling Alpha code generator, x86 code generator HL Analysis Infrastructure Graphs, sccs Presburger arithmetic (omega) Farkas lemma&“Gaussian Elimination” Interprocedural framework Garbage collection (Boehm’s) Call graph Affine partitioning for parallelism & locality Steensgaard’s alias analysis Interprocedural parallelization: array/scalar dependence/privatization Pre-release In progress

  31. Comments • Will never implement such a system if not for the infrastructure project • Enables safe type casting of objects • All objects created via factories • Owner edges embed a tree into program representation

More Related