a summary of essential abstractions
play

A Summary of Essential Abstractions Uday Khedker - PowerPoint PPT Presentation

A Summary of Essential Abstractions Uday Khedker (www.cse.iitb.ac.in/uday) GCC Resource Center, Department of Computer Science and Engineering, Indian Institute of Technology, Bombay 13 June 2014 Part 2 Methodology EAGCC-PLDI-14


  1. A Summary of Essential Abstractions Uday Khedker (www.cse.iitb.ac.in/˜uday) GCC Resource Center, Department of Computer Science and Engineering, Indian Institute of Technology, Bombay 13 June 2014

  2. Part 2 Methodology

  3. EAGCC-PLDI-14 Essential Abstractions: Methodology 1/31 Our Padagogy External View Internal View Compiler Machine descriptions Front end hooks Specifications Compiler Configuration Retargetability and building mechanism Generator Pass structure Gray box probing Generated Control flow Pass structure and IR Compiler Static and dynamic Parallelization, Vectorization plugin mechanisms Uday Khedker GRC, IIT Bombay

  4. EAGCC-PLDI-14 Essential Abstractions: Methodology 2/31 Gray Box Probing Black Box Probing . . . Phase 1 Phase 2 Phase n Observe Observe Uday Khedker GRC, IIT Bombay

  5. EAGCC-PLDI-14 Essential Abstractions: Methodology 2/31 Gray Box Probing White Box Probing . . . Phase 1 Phase 2 Phase n Observe Observe Uday Khedker GRC, IIT Bombay

  6. EAGCC-PLDI-14 Essential Abstractions: Methodology 2/31 Gray Box Probing Gray Box Probing . . . Phase 1 Phase 2 Phase n Observe Observe Observe Observe Uday Khedker GRC, IIT Bombay

  7. EAGCC-PLDI-14 Essential Abstractions: Methodology 3/31 Systematic Development of Machine Descriptions Other data types Conditional control transfers Function Calls Arithmetic Expressions Sequence of Simple Assignments involving integers MD Level 1 MD Level 2 MD Level 3 MD Level 4 MD Level 5 Uday Khedker GRC, IIT Bombay

  8. Part 3 The Framework

  9. EAGCC-PLDI-14 Essential Abstractions: The Framework 4/31 The GNU Tool Chain for C Source Program cpp cpp cc1 cc1 gcc as glibc/newlib ld Target Program Uday Khedker GRC, IIT Bombay

  10. EAGCC-PLDI-14 Essential Abstractions: The Framework 5/31 The Architecture of GCC Input Language Target Name Compiler Generation Framework Language and Machine Language Machine Machine Dependent Development Specific Time Descriptions Independent Generator Code Generic Code Code Build Selected Copied Generated Time Copied Generated Tree SSA Use Parser Gimplifier Expander Optimizer Recognizer Time Optimizer Generated Compiler ( cc1 ) Source Program Assembly Program Uday Khedker GRC, IIT Bombay

  11. Part 4 The Generated Compiler

  12. EAGCC-PLDI-14 Essential Abstractions: The Generated Compiler 6/31 Compilation Models Aho Ullman Davidson Fraser Model Model Front End Front End Aho Ullman: Instruction selection • over optimized IR using AST AST • cost based tree pattern matching Expander Optimizer Davidson Fraser: Instruction selection Register Transfers Target Indep. IR • over AST using Optimizer • structural tree pattern matching Code • naive code which is Register Transfers Generator ◮ target dependent, and is ◮ optimized subsequently Recognizer Target Program Target Program Uday Khedker GRC, IIT Bombay

  13. EAGCC-PLDI-14 Essential Abstractions: The Generated Compiler 7/31 Basic Transformations in GCC Tranformation from a language to a different language Target Independent Target Dependent Tree SSA Generate Generate Parse Gimplify Optimize RTL Optimize RTL ASM GIMPLE → RTL RTL → ASM GIMPLE Passes RTL Passes Uday Khedker GRC, IIT Bombay

  14. EAGCC-PLDI-14 Essential Abstractions: The Generated Compiler 8/31 Plugin Structure in cc1 For simplicity, we have included all passes in a single list. Actually passes are organized MD n toplev front pass into five lists and are invoked main end manager as five different sequences MD 2 code for pass 1 pass 1 langhook MD 1 . . . code for pass 2 pass 2 code for . . . language 1 expander insn data code pass generated code for expand optab table code for language 2 machine 1 . . . code for recognizer language n pass n code Uday Khedker GRC, IIT Bombay

  15. EAGCC-PLDI-14 Essential Abstractions: The Generated Compiler 9/31 The Mechanism of Dynamic Plugin pass manager code for pass code for dynamic plugin code for pass Runtime initialization of the appropriate . . . linked list of passes expander code Made possible by optab table dynamic linking . . . recognizer code for Uday Khedker GRC, IIT Bombay

  16. EAGCC-PLDI-14 Essential Abstractions: The Generated Compiler 10/31 Execution Order in Intraprocedural Passes Function 1 Function 2 Function 3 Function 4 Function 5 Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Uday Khedker GRC, IIT Bombay

  17. EAGCC-PLDI-14 Essential Abstractions: The Generated Compiler 11/31 Execution Order in Interprocedural Passes Function 1 Function 2 Function 3 Function 4 Function 5 Pass 1 Pass 2 Pass 3 Pass 4 Pass 5 Uday Khedker GRC, IIT Bombay

  18. Part 5 LTO

  19. EAGCC-PLDI-14 Essential Abstractions: LTO 12/31 Partitioned and Non-Partitioned LTO Load complete call graph Analysis Sequential Load function Load Analysis summaries but all function not bodies bodies Partitioned Mode ×× Load Load function Load groups All function Transformation all function bodies of function bodies already bodies one by one bodies loaded No need to load the entire program in memory IPA possible (multiple function bodies) Parallel transformations possible Analysis and transformations in independent processes Uday Khedker GRC, IIT Bombay

  20. EAGCC-PLDI-14 Essential Abstractions: LTO 12/31 Partitioned and Non-Partitioned LTO Load complete call graph Analysis Sequential Load function Load Analysis summaries but all function not bodies bodies Partitioned Mode ×× Load Load function Load groups All function Transformation all function bodies of function bodies already bodies one by one bodies loaded Balanced partitions -flto -flto-partitions=balanced One Partition per file -flto -flto-partitions=1to1 Partitions by number -flto --params lto-partitions=n Partitions by size -flto --params lto-min-partition=s Uday Khedker GRC, IIT Bombay

  21. EAGCC-PLDI-14 Essential Abstractions: LTO 12/31 Partitioned and Non-Partitioned LTO Load complete call graph Analysis Sequential Load function Load Analysis summaries but all function not bodies bodies Non-Partitioned Mode ×× Load Load function Load groups All function Transformation all function bodies of function bodies already bodies one by one bodies loaded Entire program needs to be loaded in memory No partitions -flto -flto-partitions=none Strictly sequential transformations Analysis and transformations in the same processes Uday Khedker GRC, IIT Bombay

  22. EAGCC-PLDI-14 Essential Abstractions: LTO 13/31 cc1 and Single Process lto1 toplev main ... compile file ... cgraph analyze function cgraph optimize ... ipa passes ... cc1 cgraph expand all functions ... tree rest of compilation Uday Khedker GRC, IIT Bombay

  23. EAGCC-PLDI-14 Essential Abstractions: LTO 13/31 cc1 and Single Process lto1 toplev main lto main ... ... compile file read cgraph and symbols ... ... cgraph analyze function materialize cgraph cgraph optimize ... ipa passes ... lto1 cgraph expand all functions ... tree rest of compilation Uday Khedker GRC, IIT Bombay

  24. EAGCC-PLDI-14 Essential Abstractions: LTO 14/31 The GNU Tool Chain for Single Process LTO Support cc1 ′ lto1 ′ cc1 common “Fat” .s files as as “Fat” .o files cc1 ′ lto1 ′ collect2 lto1 gcc common Single .s file as as Single .o file + glibc/newlib collect2 ld ld a.out file Uday Khedker GRC, IIT Bombay

  25. EAGCC-PLDI-14 Essential Abstractions: LTO 14/31 The GNU Tool Chain for Single Process LTO Support cc1 ′ lto1 ′ cc1 common Common Code (executed twice for each function in the input program for “Fat” .s files single process LTO. Once during LGEN and then during WPA + LTRANS) as as cgraph optimize ipa passes “Fat” .o files execute ipa pass list(all small ipa passes)/*!in lto*/ execute ipa summary passes(all regular ipa passes) cc1 ′ lto1 ′ collect2 lto1 gcc execute ipa summary passes(all lto gen passes) common ipa write summaries Single .s file execute ipa pass list(all late ipa passes) cgraph expand all functions as as cgraph expand function Single .o file + glibc/newlib /* Intraprocedural passes on GIMPLE, */ /* expansion pass, and passes on RTL. */ collect2 ld ld a.out file Uday Khedker GRC, IIT Bombay

  26. EAGCC-PLDI-14 Essential Abstractions: LTO 15/31 Partitioned LTO (aka WHOPR LTO) Option -flto -c WPA cc1 ′ lto1 ′ Option f1.c f1.o common -flto -o out large call graph without procedure bodies cc1 ′ lto1 ′ cc1 ′ lto1 ′ f2.c f2.o (Interproc. analysis: √ common common Tranformation: × ) cc1 ′ lto1 ′ f3.c f3.o common /tmp/ccdKEyVB.ltrans0.o (possibly multiple files) (possibly multiple files) cc1 ′ lto1 ′ out LGEN common LTRANS Uday Khedker GRC, IIT Bombay

  27. EAGCC-PLDI-14 Essential Abstractions: LTO 16/31 (Non-Partitioned LTO) IPA + Transformations Option -flto -c Option cc1 ′ lto1 ′ -flto -o out f1.c f1.o -flto-partition=none common large call graph with procedure bodies cc1 ′ lto1 ′ cc1 ′ lto1 ′ f2.c f2.o (Interproc. analysis: √ common common Transformation: √ ) This IPA can examine function bodies also cc1 ′ lto1 ′ f3.c f3.o common out LGEN Uday Khedker GRC, IIT Bombay

  28. Part 6 The Build Process

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend