Final Examination. Winter Problem Points Score. Total 180

Similar documents
CS143 Final Spring 2016

CS243 Homework 1. Winter Due: January 23, 2019 at 4:30 pm

CS143 Final Fall 2009

Name: CIS 341 Final Examination 10 December 2008

CIS 341 Final Examination 3 May 2011

This test is not formatted for your answers. Submit your answers via to:

CIS 341 Final Examination 30 April 2013

Lecture 19. Software Pipelining. I. Example of DoAll Loops. I. Introduction. II. Problem Formulation. III. Algorithm.

Computer Science 320: Final Examination

EECS 470 Midterm Exam Winter 2015

CS140 Operating Systems and Systems Programming Midterm Exam

CS144: Intro to Computer Networks Homework 1 Scan and submit your solution online. Due Friday January 30, 4pm

Problem Score Max Score 1 Syntax directed translation & type

Calculus II (Math 122) Final Exam, 11 December 2013

University of Waterloo Midterm Examination Solution

Structure of Computer Systems

CS140 Operating Systems and Systems Programming Final Exam

CS140 Operating Systems and Systems Programming Midterm Exam

Lecture 21. Software Pipelining & Prefetching. I. Software Pipelining II. Software Prefetching (of Arrays) III. Prefetching via Software Pipelining

6.034 Quiz 1, Spring 2004 Solutions

CS144: Intro to Computer Networks Homework 1 Scan and submit your solution online. Due Friday January 30, 4pm

COS 471A,COS 471B/ELE 375 Midterm

Homework #6 (Constraint Satisfaction, Non-Deterministic Uncertainty and Adversarial Search) Out: 2/21/11 Due: 2/29/11 (at noon)

ˆ The exam is closed book, closed calculator, and closed notes except your one-page crib sheet.

EECS 492 Midterm #1. Example Questions. Note: Not a complete exam!

Computer Architecture CS372 Exam 3

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

The exam is closed book, closed calculator, and closed notes except your one-page crib sheet.

ENGR 100 Midterm (CSE Part) Winter 2014

Spring 2 Spring Loop Optimizations

Math 52 Final Exam March 16, 2009

CS140 Operating Systems and Systems Programming Final Exam

CS143 Midterm Spring 2014

1 Tree Search (12 points)

What Compilers Can and Cannot Do. Saman Amarasinghe Fall 2009

EXAM #1. CS 2410 Graduate Computer Architecture. Spring 2016, MW 11:00 AM 12:15 PM

EECS 373 Midterm Winter 2013

MATH 1075 Final Exam

EXAM 1 SOLUTIONS. Midterm Exam. ECE 741 Advanced Computer Architecture, Spring Instructor: Onur Mutlu

Fall Compiler Principles Lecture 12: Register Allocation. Roman Manevich Ben-Gurion University

CS 2506 Computer Organization II Test 2

Note that there are questions printed on both sides of each page!

G Programming Languages - Fall 2012

CS433 Midterm. Prof Josep Torrellas. October 16, Time: 1 hour + 15 minutes

6.034 QUIZ 1. Fall 2002

CS 5803 Introduction to High Performance Computer Architecture: Arithmetic Logic Unit. A.R. Hurson 323 CS Building, Missouri S&T

Do not start the test until instructed to do so!

4 Search Problem formulation (23 points)

CS145 Midterm Examination

CS-171, Intro to A.I. Mid-term Exam Winter Quarter, 2016

Math 124 Final Examination Winter 2016 !!! READ...INSTRUCTIONS...READ!!!

CS 2504 Intro Computer Organization Test 1

CS3330 Fall 2014 Exam 2 Page 1 of 6 ID:

MIT Spring 2011 Quiz 3

CS 3330 Exam 2 Fall 2017 Computing ID:

Code Generation. CS 540 George Mason University

MCS-378 Intraterm Exam 1 Serial #:

Compiler Architecture

CS244 Advanced Topics in Computer Networks Midterm Exam Monday, May 2, 2016 OPEN BOOK, OPEN NOTES, INTERNET OFF

CS140 Operating Systems and Systems Programming Final Exam

CS 3114 Data Structures and Algorithms Test 1 READ THIS NOW!

Binary Adders. Ripple-Carry Adder

NAME: Problem Points Score. 7 (bonus) 15. Total

CS 2506 Computer Organization II

Updated Exercises by Diana Franklin

COMPUTATIONAL PROPERIES OF DSP ALGORITHMS

Flow Graph Theory. Depth-First Ordering Efficiency of Iterative Algorithms Reducible Flow Graphs

CS 155 Final Exam. CS 155: Spring 2005 June 2005

FAMILY NAME: (Print in ink) GIVEN NAME(S): (Print in ink) STUDENT NUMBER: SIGNATURE: (in ink) (I understand that cheating is a serious offense)

To earn the extra credit, one of the following has to hold true. Please circle and sign.

Spring 2017 CS 1110/1111 Exam 1

EECS 470 Midterm Exam

CS 140 Midterm Examination Winter Quarter, 2012

CS 6353 Compiler Construction, Homework #3

CSE 401 Final Exam. March 14, 2017 Happy π Day! (3/14) This exam is closed book, closed notes, closed electronics, closed neighbors, open mind,...

University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Sciences. Spring 2010 May 10, 2010

CS 2506 Computer Organization II

Lecture 31: Building a Runnable Program

TSEA 26 exam page 1 of Examination. Design of Embedded DSP Processors, TSEA26 Date 8-12, G34, G32, FOI hus G

Supplement for MIPS (Section 4.14 of the textbook)

CS 540: Introduction to Artificial Intelligence

CSE331 Winter 2014, Midterm Examination February 12, 2014

Stanford University Computer Science Department CS 295 midterm. May 14, (45 points) (30 points) total

Instruction Scheduling

You have 45 minutes to work on this exam. It is a "closed-book/closed-notes" test.

CPSC 313, 04w Term 2 Midterm Exam 2 Solutions

EECS 470 Midterm Exam

CS 3114 Data Structures and Algorithms READ THIS NOW!

CS4411 Intro. to Operating Systems Final Fall points 12 pages

ECE 341 Midterm Exam

Midterm II CS164, Spring 2006

CS 351 Exam 2, Fall 2012

The x-intercept can be found by setting y = 0 and solving for x: 16 3, 0

EECS 470 Midterm Exam Winter 2009

CS 1301 Exam 1 Fall 2010

Cornell University Computer Science 211 Second Preliminary Examination 18 April 2006

Fall 2011 PhD Qualifier Exam

Final Exam. If you plan to solve a problem using a standard graph algorithm then you should clearly

ECE 341 Final Exam Solution

CS 5565 Final Exam. Name (printed)

Transcription:

CS243 Winter 2002-2003 You have 3 hours to work on this exam. The examination has 180 points. Please budget your time accordingly. Write your answers in the space provided on the exam. If you use additional scratch paper, please turn that in as well. Your Name: In accordance with both the letter and spirit of the Honor Code, I have neither given nor received assistance on this examination. Signature: Problem Points Score 1 10 2 20 3 30 4 20 5 30 6 30 7 40 Total 180 Winter 2003 Page 1 of 13

1. (10 points) Suppose you have a machine with 3 registers. Can you find a register allocation for the following interference graph such that no spilling is necessary? Your answer may be one of: yes, no, I don t know. If the answer is yes, specify a register assignment. If the answer is no, explain why. 1 2 3 8 4 5 6 7 9 Winter 2003 Page 2 of 13

2. (20 points) Briefly give one important advantage and disadvantage for each of the following styles of garbage collection. a. Reference counting Advantage: Disadvantage: b. Copying garbage collection Advantage: Disadvantage: c. Generational garbage collection Advantage: Disadvantage: d. Incremental garbage collection Advantage: Disadvantage: Winter 2003 Page 3 of 13

3. (30 points) Consider the following control flow graph: Entry A B C D F E G H I J K Exit L a. Give a reverse post-ordering for this flow graph. Winter 2003 Page 4 of 13

b. Draw the dominator tree for this graph. c. Find the natural loops in this graph. d. Is the flow graph reducible? Explain. Winter 2003 Page 5 of 13

e. Consider a data-flow solver that sweeps through all the nodes in reverse post-order until there are no more changes. Assume that the solver needs to iterate through the nodes once after the final answer is reached to detect convergence. If we apply the solver to the dataflow problem of finding dominators, what is the maximum number of times this solver has to iterate before it converges for the above program. Justify your answer. f. What is the maximum number of times a reverse post-order solver has to iterate to find reaching definitions in this program? To justify the answer to part (e), show an example that requires the maximum number of iterations. You may do so by placing one definition in the program and identifying a program point whose value is not correct until the last but one iteration. Winter 2003 Page 6 of 13

4. (20 points) Show the result of applying lazy code motion to the following program. Show the result of the optimization -- it is not necessary to show any intermediate steps. (Introduce new basic blocks as necessary). B 1 ENTRY u=a+b B 2 B 3 B 4 v=a+b B 5 B 6 EXIT B 7 w=a+b B 8 B 9 B 10 b=read() B 11 Winter 2003 Page 7 of 13

*** Extra page for answers *** Winter 2003 Page 8 of 13

5. (30 points) Design a monotone iterative data flow analysis algorithm to find the signs of variables in a program. Your algorithm must determine, for each basic block, if each variable in the program is positive, non-positive, equal to zero, negative, non-negative, or unknown. The instructions in the program are: assignments, additions, subtractions, squares (square(x)=x*x), conditional and unconditional branches. You do not need to optimize the branch operations. a. What is the direction of your data flow analysis? b. Draw a diagram of the semi-lattice for one variable, identifying the top and bottom elements clearly. c. How do you initialize the iterative algorithm? d. Define the transfer function of a basic block. e. Is your transfer function distributive? f. Will your algorithm converge? If so, why? Winter 2003 Page 9 of 13

6. (30 points) Consider an architecture that can issue one memory operation (LOD, STR), one arithmetic operation (ADD, MUL), and one control flow operation simultaneously. Addresses are of the form A[r+c], where r is a register, A is a base address, and c is a constant. LOD, STR, and ADD have latency 1; MUL has latency 2 (and is perfectly pipelined). All registers that are read in a cycle are read at the beginning of the cycle; all registers that are written are written at the end of the clock cycle. a. The following code is handed to a scheduler: (1) LOD r1 = A[r2+0] (2) MUL r3 = r3 * r4 (3) ADD r3 = r4 + r1 (4) STR B[r2+0] = r3 List all dependencies in the following code and classify them as true, anti-, or output dependencies. b. Consider the following code: L: (1) LOD r2 = A[r1+0] (2) LOD r3 = B[r1+0] (3) MUL r3 = r3 * r3 (4) ADD r2 = r2 + r3 (5) STR C[r1+0] = r2 (6) LOOP L, r1, 1, 1000 i. Give a lower bound on the initiation interval for a software pipelined version of this code? Justify your answer by showing the modulo resource reservation table. ii. Show the steady state of the software pipelined code. Use modulo variable expansion if necessary. Assume as many registers as necessary are available. Winter 2003 Page 10 of 13

*** Extra page for answers *** Winter 2003 Page 11 of 13

7. (40 points) Consider a small programming language defined as follows: A program is a statement. A statement is a sequence of primitive or loop statements separated by semi-colons. Let u, v, w below represent variables. A primitive statement can be one of: a. constant assignments: u = <constant> b. copy operations: u = v c. additions: u = v + w, u = v + <constant> A loop statement: Loop <constant> times { <statement> } where the constant is a positive number. Devise a general region-based constant propagation algorithm that can, for example, find the constant value of variable d in the following program: a = 1 b = 2 c = a + b; Loop 10 times { b = b + 1; loop 100 times { a = a + c; } b = b + 4; } d = a + b Winter 2003 Page 12 of 13

*** Extra page for answers *** Winter 2003 Page 13 of 13