Advanced Compiler Construction

Similar documents
Program Analysis And Its Support in Software Development

Advanced Compiler Construction Theory And Practice

CS415 Compilers Overview of the Course. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University

Administration. Prerequisites. Meeting times. CS 380C: Advanced Topics in Compilers

DEPARTMENT OF COMPUTER SCIENCE

USC 227 Office hours: 3-4 Monday and Wednesday CS553 Lecture 1 Introduction 4

Office Hours: Mon/Wed 3:30-4:30 GDC Office Hours: Tue 3:30-4:30 Thu 3:30-4:30 GDC 5.

UG3 Compiling Techniques Overview of the Course

CSCI 565 Compiler Design and Implementation Spring 2014

CSE 501: Compiler Construction. Course outline. Goals for language implementation. Why study compilers? Models of compilation

CS 701. Class Meets. Instructor. Teaching Assistant. Key Dates. Charles N. Fischer. Fall Tuesdays & Thursdays, 11:00 12: Engineering Hall

CS 406/534 Compiler Construction Putting It All Together

Building a Runnable Program and Code Improvement. Dario Marasco, Greg Klepic, Tess DiStefano

Topics on Compilers

Advanced Compiler Construction

Introduction to Machine-Independent Optimizations - 1

ECE573 Introduction to Compilers & Translators

CSC D70: Compiler Optimization

Enhancing Parallelism

Overview of the Class

Overview of the Course

Lecture 17. Intro to Instruc.on Scheduling. Reading: Chapter Carnegie Mellon Todd C. Mowry 15745: Intro to Scheduling 1

Principles of Compiler Construction ( )

Compiler techniques for leveraging ILP

CS 241 Data Organization using C

Overpartioning with the Rice dhpf Compiler

Academic Course Description. EM2101 Computer Architecture

CS4961 Parallel Programming. Lecture 10: Data Locality, cont. Writing/Debugging Parallel Code 09/23/2010

The View from 35,000 Feet

COSE212: Programming Languages. Lecture 0 Course Overview

CS415 Compilers Overview of the Course. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University

ET345P Control Systems [Onsite]

Advanced Instruction-Level Parallelism

CS 293S Parallelism and Dependence Theory

Objective. We will study software systems that permit applications programs to exploit the power of modern high-performance computers.

Principles of Compiler Construction ( )

Compilers for Modern Architectures Course Syllabus, Spring 2015

Usually, target code is semantically equivalent to source code, but not always!

CS 4110 Programming Languages & Logics. Lecture 35 Typed Assembly Language

Advanced Compiler Design ( ) Fall Semester Project Proposal. Out: Oct 4, 2017 Due: Oct 11, 2017 (Revisions: Oct 18, 2017)

Donn Morrison Department of Computer Science. TDT4255 ILP and speculation

CS 553: Algorithmic Language Compilers (PLDI) Graduate Students and Super Undergraduates... Logistics. Plan for Today

BIRLA INSTITUTE OF TECHNOLOGY AND SCIENCE, Pilani Pilani Campus Instruction Division. SECOND SEMESTER Course Handout Part II

Software Reliability and Reusability CS614

Static Program Analysis

The Processor: Instruction-Level Parallelism

Compilers and Interpreters

COMP 250. Lecture 36 MISC. - beyond COMP final exam comments

CS6303 Computer Architecture Regulation 2013 BE-Computer Science and Engineering III semester 2 MARKS

Syllabus COSC-051-x - Computer Science I Fall Office Hours: Daily hours will be entered on Course calendar (or by appointment)

Real Processors. Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University

CS415 Compilers Register Allocation. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University

Course Administration

Computer Systems Architecture

Using Cache Models and Empirical Search in Automatic Tuning of Applications. Apan Qasem Ken Kennedy John Mellor-Crummey Rice University Houston, TX

CS 241 Data Organization. August 21, 2018

Prof. Hakim Weatherspoon CS 3410, Spring 2015 Computer Science Cornell University. P & H Chapter 4.10, 1.7, 1.8, 5.10, 6

Introduction. L25: Modern Compiler Design

The University of Iowa. 22c181: Formal Methods in Software Engineering. Spring Course Overview

Code Shape II Expressions & Assignment

Programming Project 4: COOL Code Generation

CS553 Lecture Dynamic Optimizations 2

Introduction to Compilers

Architectures for Instruction-Level Parallelism

378: Machine Organization and Assembly Language

Optimising with the IBM compilers

Lecture 1: Introduction

San José State University Department of Computer Science CS-144, Advanced C++ Programming, Section 1, Spring 2018

Overview of the Class

6. Intermediate Representation

Compilers. Computer Science 431

Static Program Analysis

UNIT 8 1. Explain in detail the hardware support for preserving exception behavior during Speculation.

Welcome to... CS113: Introduction to C

Lecture: Static ILP. Topics: loop unrolling, software pipelines (Sections C.5, 3.2)

CSci Introduction to Operating Systems. Administrivia, Intro

San Jose State University College of Science Department of Computer Science CS151, Object-Oriented Design, Sections 1,2 and 3, Spring 2017

LIMITS OF ILP. B649 Parallel Architectures and Programming

understanding recursive data types, recursive functions to compute over them, and structural induction to prove things about them

GETTING STARTED WITH CANVAS QUICK STEPS

Advanced Compiler Design. CSE 231 Instructor: Sorin Lerner

6. Intermediate Representation!

Syllabus of ENPM 691: Secure Programming in C

CSE 504: Compiler Design

CS 526 Advanced Topics in Compiler Construction. 1 of 12

Overview of a Compiler

15-740/ Computer Architecture

KOMAR UNIVERSITY OF SCIENCE AND TECHNOLOGY (KUST)

Compiling Techniques

Code Optimization. Code Optimization

Lecture 10: Static ILP Basics. Topics: loop unrolling, static branch prediction, VLIW (Sections )

Intra-procedural Data Flow Analysis Introduction

G.PULLAIH COLLEGE OF ENGINEERING & TECHNOLOGY

Optimization Prof. James L. Frankel Harvard University

CS415 Compilers. Intermediate Represeation & Code Generation

Under the Compiler's Hood: Supercharge Your PLAYSTATION 3 (PS3 ) Code. Understanding your compiler is the key to success in the gaming world.

CS 525 Advanced Database Organization - Spring 2017 Mon + Wed 1:50-3:05 PM, Room: Stuart Building 111

CS120 Computer Science I. Instructor: Jia Song

COMP 322: Fundamentals of Parallel Programming

Lec 25: Parallel Processors. Announcements

Transcription:

Advanced Compiler Construction Qing Yi class web site: www.cs.utsa.edu/~qingyi/cs6363 cs6363 1

A little about myself Qing Yi Ph.D. Rice University, USA. Assistant Professor, Department of Computer Science Office: SB 4.01.30 Phone : 458-5671 Research Interests Compiler construction program analysis and optimization for high-performance computing Programming languages type systems, object-oriented design Software engineering automatic code generation; systematic error-discovery and verification of software Overall goal: develop tools to improve both the productivity and efficiency of programming cs6363 2

General Information Class website www.cs.utsa.edu/~qingyi/cs6363 Check for class handouts and announcements Office hours:mw 3:30-4pm 5:15-5:45pm; by appointment Textbook Optimizing compilers for Modern Architectures: A dependence-based Approach Ken Kennedy and Randy Allen, Morgan-Kauffman Publishers Inc. Requirements Basic understanding of algorithms, programming languages, and compilers Grading In class exercises and quizzes: 30% Research paper presentation: 20% Paper review: 10% Research project: 40% cs6363 3

Program Optimization Projects In order to optimize a program, a tool must be built to Understand (parse/unparse) a programming language Analyze the program to determine which potential optimizations are possible (safety analysis) Analyze the program to determine which transformations are profitable and how to apply the transformations (optimization configuration) Ways to resolve the problem Build a small parser/unparser for a subset of the C language Easy and flexible if publishing paper is all you want Use existing infrastructures from open-source compilers and languages We provide the ROSE C/C++ compiler and the POET language (an interpreted language for building ad-hoc optimizers/translators) Your project can focus on one of the analysis or transformation aspects of performance optimizations cs6363 4

Acknowledgements Slides from the compiler optimization class (comp515) of Rice University By Prof. Ken Kennedy www.cs.rice.edu/~ken/comp515 By prof. Vevek Sarkar www.cs.rice.edu/~vs3/comp515/ cs6363 5

High performance computing on modern machines Applications must efficiently manage architectural components Pipelining Multiple execution units --- pipelined Vector operations, multi-core Parallel processing Shared memory, distributed memory, message-passing VLIW and Superscalar instruction issue Registers Cache hierarchy Combinations of the above --- parallel-vector machines What are the compilation challenges? cs6363 6

Optimizing For High Performance Optimization means eliminating inefficiencies in programs Eliminate redundancy: if an operation has already been evaluated, don t do it again Especially if the operation is inside loops or part of a recursive evaluation All optimizing compilers apply redundancy elimination, e.g., loop invariant code motion, value numbering, global RE, PRE Resource management: reorder operations and data to better map to the targeting machine Reorder computation(operations) parallelization, vectorization, pipelining, VLIW, memory reuse Instruction scheduling and loop transformations Re-organization of data Register allocation, regrouping of arrays and data structures cs6363 7

Optimizing Compilers For Modern Architectures Sophisticated compiler optimizations beyond traditional redundancy elimination Parallelization and vectorization memory hierarchy management Instruction scheduling Interprocedural (whole-program) optimizations Goal: reorder operations to better manage the targeting machine Most compilers focus on optimizing loops, why? This is where the application spends most of its computing time What about recursive function/procedural calls? Extremely important, but often left unoptimized cs6363 8

Compiler Technologies Source-level Program Transformations Most architectural issues can be dealt with by restructuring transformations of program source Vectorization, parallelization, cache reuse enhancement Challenges: Determining when transformations are legal Selecting transformations based on profitability Low level code generation Some issues must be dealt with at a lower level Prefetch insertion Instruction scheduling All require some understanding of the ways that instructions and statements depend on one another (share data) cs6363 9

Dependence-based Optimization Vectorization and Parallelization require a deeper analysis than optimization for scalar machines Bernstein s Conditions: it is safe to run two tasks R1 and R2 in parallel if none of the following holds: R1 writes into a memory location that R2 reads R2 writes into a memory location that R1 reads Both R1 and R2 write to the same memory location Dependence is the theory that makes this possible There is a dependence between two statements if they might access the same location, there is a path from one to the other, and one access is a write Dependence has other applications Memory hierarchy management Restructuring programs to make better use of cache and registers Includes input dependences Scheduling of instructions cs6363 10

Dependence --- a Static Program Analysis Technique Program analysis --- support software development and maintenance Compilation --- identify errors without running program Smart development environment (check simple errors as you type the code) Program Optimization --- cannot not change the meaning of the program Improve performance, reduce resource consumption, Code revision/re-factoring ==> reusability, maintainability, Program correctness --- Is the program safe? Is it dependable? Program verification --- is the program guaranteed to satisfy certain properties? Is the implementation safe, secure, and dependable? Program integration --- are there any communication errors among different components of a collaborated project? Program understanding --- extract high-level semantics from low-level implementations (reverse engineering) In contrast, if the program needs to be run to figure out information, it is called dynamic program analysis. Dependence: models the re-ordering constraints between operations cs6363 11

Focus of this class Reorder computation to better map to the targeting machine Focus on using dependence information to guide optimizations of loops Determine what transformations are safe and profitable Introduce other optimizations applied at the source level Regrouping of data, prefetching techniques Instruction scheduling and redundancy elimination are covered in cs5363 and not covered here Whole program analysis and optimizations Interprocedural control-flow analysis, aliasing analysis, pointer analysis Extend the application scope of optimizations Research experience Study literature on cutting edge optimizations Object-oriented programming, data layout optimizations, interprocedural optimizations, tuning of optimization parameters Research project Identify an important problem, solve the problem, evaluate the solution. cs6363 12

Syllabus Introduction Compilation for parallel machines and automatic detection of parallelism. Dependence Theory and Practice Types of dependences; Testing for dependence; Control Dependence. Types of branches. If conversion. Program dependence graph. Preliminary Transformations Loop normalization, scalar data flow analysis, induction variable substitution, scalar renaming. Parallel Code Generation Fine- and Coarse-Grained parallel code generation and loop transformations to enable parallelism. Memory Hierarchy Management The use of dependence in scalar register allocation and management of the cache memory hierarchy. Interprocedural Analysis and Optimization Management of interprocedural analysis and optimization. cs6363 13

Roadmap Week1-8 --- Fundamental theories Materials from the textbook Instructors giving lectures Students select from a pool of papers and project ideas Initial project plan due Each project must resolves at least one non-trivial problem and evaluates the solution Week9-13--- theory applied to solve real problems Materials from the research literature Student paper presentations Class discussion and paper reviews Project intermediate and final report cs6363 14