CS243: Program Analysis and Optimizations Winter 2025
This page is updated frequently, so check back often. All materials for the course will be posted here.What do we teach?
- How do we make high-level programming languages efficient by optimizing the code? (Data-flow analysis)
- Machine learning and scientific computing need a lot of cycles; machines such as GPUs are complex to code. How do we automatically generate efficient code for these machines effectively. (Parallelism and Locality)
- Can we use program analysis to improve the quality of the code? (Satisfiability Modulo Theories)
- How do we automatically manage memory efficiently so users do not have to manage it themselves? (Garbage collection)
- The highest programming language is obviously natural language. With the recent introduction of large language models such as GPT3 and CodeX, how do we let consumers code in natural language using machine learning? Note: no prior knowledge in machine learning is needed. (Neural networks)
How do you learn this?
As compilers are one of the most complex programs we write, by teaching compilers, we are also teaching software engineering. It is a course where programming and mathematics meet. We show how to apply general mathematical concepts (fixpoint computations, graph theory, linear algebra, binary decision diagrams, neural networks) to handle various complex programming problems. You will learn how to formulate solutions to problems, and not just memorizing prior work.
How is the course structured?
- Interactive lectures, textbook reading.
- Programming assignments analyze Java code.
- Written assignments explore mathematical concepts from lectures.
- Problem sessions for discussion.
- Ed for offline questions.
- 2 Exams.
Logistics When, where, what and how
Lectures | Monday and Wednesday 3:00 pm - 4:20 pm, Gates B3 |
Review Session | Friday 2:30 pm - 3:20 pm, Hewlett 201 |
Prerequisites | CS 103 or CS 103B, and CS 107; Java programming language experience |
Textbook | Compilers: Principles, Techniques, and Tools (Second Edition), Alfred V. Aho, Monica S. Lam, Ravi Sethi, Jeffrey D. Ullman, Addison-Wesley, 2007. |
Class Q&A Website | CS243 on Ed, for all questions related to course material |
Videos of Lectures | CS243 Canvas Page |
Staff Mailing List | |
Office Hours Sign-up | QueueStatus |
SCPD Office Hours | Sign-up on QueueStatus, write SCPD in name |
Midterm | Wednesday, Feb 12, 2024: 3:00pm - 4:20pm (in class) |
Final Exam | Tuesday, Mar 18, 2025: 8.30am - 11.30am, Location TBD |
Staff Professor and TA details
Monica Lam, Instructor
Office | Gates 344 |
Office Hours | Wednesdays: after class |
Contact Details |
Angelica Teaupa, Admin
Office | Gates 372 |
Phone | (650) 724-5040 |
Robert Chen, TA
Office | Huang Basement and Zoom |
Office Hours | Tuesday 5-6pm (Zoom) / Thursday 3-4pm (Huang) |
Contact Details |
Varun Desai, TA
Office | Huang Basement and Zoom |
Office Hours | Monday 2-3pm (Huang) / Thursday 5-6pm (Zoom) |
Contact Details |
Tentative Schedule Subject to change
Date | Topic | Reading | Lecture notes | Assignment out | Assignment due | Review Session (Fri) |
---|---|---|---|---|---|---|
Jan 6 [Mon] | Introduction | 1.1-5, 8.4, 8.5, 9.1 | Lecture 1 | |||
Jan 8 [Wed] | Dataflow Analysis Introduction | 9.2 | Lecture 2 | |||
Jan 13 [Mon] | Dataflow Analysis Foundation | 9.3 | Lecture 3 | |||
Jan 15 [Wed] | Constant Propagation, Loops | 9.4, 9.6 | Lecture 4 | HW1, Gradiance | Data flow analysis | |
Jan 20 [Mon] | holiday | |||||
Jan 22 [Wed] | Partial Redundancy Elimination | 9.5 | ||||
Jan 27 [Mon] | Register Allocation | 8.8 | ||||
Jan 29 [Wed] | Instruction Scheduling | 10.1–10.4 | ||||
Feb 3 [Mon] | Software Pipelining | 10.5 | ||||
Feb 5 [Wed] | Parallelization | 11.1–11.4, 11.6 | ||||
Feb 10 [Mon] | Loop Transformations | 11.7-11.9 | ||||
Feb 12 [Wed] | Midterm (in class) | |||||
Feb 17 [Mon] | holiday | |||||
Feb 19 [Wed] | Pipelined Parallelism | 11.8, 11.9 | ||||
Feb 24 [Mon] | Locality + Parallelism | 11.9 - 11.11 | ||||
Feb 26 [Wed] | SSA and SMT (Satisfiability Modulo Theories) Intro | |||||
Mar 3 [Mon] | SMT Solvers | |||||
Mar 5 [Wed] | Garbage Collection | 7.4-7.7.4 | ||||
Mar 10 [Mon] | Pointer Analysis | 12 | ||||
Mar 12 [Wed] | Conversational Interface to Hybrid Data Sources | |||||
Mar 18 [Tue] | Final (8:30am - 11:30am), Location: TBD |
Handouts and Graded Assignments
Lecture notes will be available for download by the morning of the lecture. Assignment handouts will be available on this page on the day it is assigned. Unless otherwise stated, written assignments should be submitted through Gradescope.
CS243 will be using the Gradiance automated homework system for some of
the required work. You should open your free account at
www.gradiance.com/services
and then sign up for the class using the "class token" 9636EBF6
.
Gradiance looks like multiple-choice questions, but it is really quite different. You are given problems to work out, just as you would in an ordinary homework. You are then given a multiple-choice question to test whether or not you have the correct solution. If you get a choice wrong, you are given a hint and encouraged to try again. You are allowed to try as many times as you like, and the goal is to get everything right eventually. To avoid repeated guessing on one problem at a time, you need to repeat all the questions each time you submit, and you will be given a different set of choices each time.
Assignment Policy
Group Work
Homework will consist of both written and programming assignments. You are encouraged to work on the programming assignments in groups of two, but you must do the written assignments by yourself.
Late Policy
In general, no late assignments are accepted. However, you have two grace days for the entire quarter. That means you can be late by one day for two assignments, or use the two days up for one assignment.
Submission
Programming assignments will have specific submission instructions included with the handouts. We will use a certain amount of automatic grading to help us deal with the massive amounts of code everyone submits, so please follow the submission instructions exactly as written!
The written homework should be submitted via Gradescope. You may access Gradescope through the corresponding tab in Canvas.
We will also assign some homework via Gradiance, as described above. If you have any issues accessing the Gradiance site, please contact the TAs.
Honor Code Cheating and Plagiarism is a no-no
You are free to discuss the assignment and solutions with others. However, you must write your own assignment, and must not represent any portion of others' work as your own. Anybody violating the honor code will be referred to the Office of Community Standards. If convicted, the normal penalty is a quarter suspension or worse.