Important #1: Click to sign up for this class on Piazza!
Important #2: Click to register with Gradiance with class token 33D8AF0C.

What do we teach?

  • 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)
  • The highest programming language is obviously natural language. Can we program our virtual assistant to perform compound tasks in natural language? We use machine learning techniques to map natural language into formal languages. Note: no prior knowledge in machine learning is needed. (Neural networks, Satisfiability Modulo Theories)
  • Can we use program analysis to automatically detect security bugs in programs? (Pointer analysis)
  • How do we automatically manage memory efficiently so users do not have to manage it themselves? (Garbage collection)
  • How do we make high-level programming languages efficient by optimizing the code? (Data-flow analysis)

How do you learn this?

This is a course where math and programming meet. Learning compiler techniques has much in common with learning mathematical proofs. You learn by trying, finding your own insights. This means the assignments can take a variable amount of time! We want you to formulate your own variations of problems and solve them.

How is the course structured?

  • Highly interactive lectures, textbook reading.
  • Programming assignments analyze Java code.
  • Problem sessions for discussion.
  • Piazza for offline questions.
  • Midterm and Final.

Logistics When, where, what and how

Lectures Monday and Wednesday 4:30 pm - 5:50pm in Gates B03
Review Session Friday 3:30pm - 4:30pm in Gates B03
Prerequisites CS 103 or CS 103B, and CS 107; Java programming language experience
Textbook Compilers: Principles, Techniques, & Tools (Second Edition), Alfred V. Aho, Monica S. Lam, Ravi Sethi, Jeffrey D. Ullman, Addison-Wesley, 2007.
Class Q&A Website CS243 on Piazza - for all questions related to the material.
Videos of Lectures SCPD Webcast for Stanford Students
Staff Mailing List for administrative questions
Midterm February 13 in Gates B03
Final March 23 (Friday) 3:30pm-6:30pm, Location: Gates B03

Where do I ask questions?

All questions related to the material should go to Piazza. Using Piazza for questions should significantly decrease the average response time, since there are more instructor/TAs and students there to see the question. If another student can answer the question, that will help them learn, too.

Administrative questions should all go to Please do not email individual staff members.

Grading Policy

Assignments 55%
Midterm 15%
Final 30%
Lab Extra Credit up to 10% (applied after curve)

Staff Professor and TA details

IMPORTANT Contact us using the for administrative questions.

Monica Lam, Instructor

Office Gates 422
Office Hours Mondays 2:00pm - 3:00pm
Gates 422
Contact Details

Dan Moreau, Admin

Office Gates 405
Phone (650) 723-1658

How are office hours structured?

The TAs each hold office hours twice a week. The instructor holds office hours by arrangement via email.

SCPD students Join the Google Hangout during office hours (link posted on Piazza).

Varun Ramesh, TA

Office Huang Basement
Office Hours Tuesday 6PM - 8PM, Friday 6PM - 8PM
Contact Details

Amelia Vu, TA

Office Huang Basement
Hours Mondays 10:30 - 11:30 AM Wednesdays 1 - 3 PM Thursdays 2 - 3 PM
Contact Details

Tentative Schedule Subject to change

Date Topic Reading Lecture notes Assignment out Assignment due
Jan 7 [Mon]Introduction1.1-5, 8.4, 8.5, 9.1Lecture 1 Handout
Jan 9 [Wed]Dataflow Analysis Introduction9.2Lecture 2 Handout, Slides
Jan 14 [Mon]Dataflow Analysis Foundation9.3Lecture 3 Handout, Slides
Jan 16 [Wed]Constant Propagation, Loops9.4, 9.6Lecture 4 Handout, SlidesHW1 SolutionJan 23
Jan 21 [Mon]holiday
Jan 23 [Wed]JoeQ FrameworkJoeQ Handout, SlidesHW2 hw2.zipJan 30
Jan 28 [Mon]Partial Redundancy Elimination9.5Lecture 5 Handout, Slides
Jan 30 [Wed]Register Allocation8.8Lecture 6 Handout, SlidesHW3 SolutionFeb 6
Feb 4 [Mon]Instruction Scheduling10.1-10.4Lecture 7 Handout, Slides
Feb 6 [Wed]Software Pipelining10.5Lecture 8 Handout, SlidesHW4 hw4.zipFeb 20
Feb 11 [Mon]Parallelization11.1-11.4, 11.6Lecture 9 Handout, Slides
Feb 13 [Wed]MidtermSolutions
Feb 18 [Mon]holiday
Feb 20 [Wed]Loop Transformations11.7-11.9Lecture 10 Handout, SlidesHW5 SolutionFeb 27
Feb 25 [Mon]Pipelined Parallelism11.8, 11.9Lecture 11 Handout, Slides
Feb 27 [Wed]Pointer Analysis12Lecture 12 HandoutHW6 hw6.zipMarch 6
Mar 4 [Mon]BDDs in Pointer Analysis12Lecture 13 Handout
Mar 6 [Wed]Satisfiability Modulo Theories (SMT)Lecture 14 Handout, SlidesHW7 SolutionMarch 13
Mar 13 [Wed]Garbage Collection7.4 - 7.7.4Lecture 15 Handout, Slides
Mar 11 [Mon]Natural Language ProgrammingLecture 16 Handout
Mar 22 [Fri]Final (3:30 pm - 6:30 pm,

Handouts and Graded Assignments What happens with physical materials

CS243 will be using the Gradiance automated homework system for some of the required work. You should open your free account at and then sign up for the class using the "class token" 33D8AF0C.

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.

SCPD students: Please download the lecture notes before the lecture; the material will be available by the morning of the lecture. Please submit written assignments to us by emailing them to the staff mailing list and include the homework route form with your submission. We will return the graded homeworks back to you through SCPD distribution (SCPD students only).

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.


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!

Some of the written homework should be submitted via Gradiance, as described above. If you have any issues accessing the Gradiance site, please contact the TAs.

Where are the assignments?

All assignments are posted on the schedule

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 Judical-Affairs Office. If convicted, the normal penalty is a quarter suspension or worse.

The full honor code can be found here

© Stanford 2014 | Built using the Bootstrap framework by your friendly TA