CS498MG Midterm Exam - Spring 2010 - Program Optimization - Prof. Maria J. Garzaran, Exams of Computer Science

A midterm exam for a program optimization course offered in spring 2010. The exam covers topics such as measuring performance, data dependences, loop optimization, and software pipelining. Students are required to answer multiple-choice questions and provide justifications for their answers.

Typology: Exams

2010/2011

Uploaded on 06/14/2011

koofers-user-j9p
koofers-user-j9p 🇺🇸

10 documents

1 / 10

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS498MG
Program Optimization
Spring 2010
Midterm Exam
NOTE: This is a closed book exam. If you have doubts, or a question is ambiguous,
please make a reasonable assumption and state it.
Name:
Problem No.
Score
1 (15 pts)
2 (15 pts)
3 (10 pts)
4 (10 pts)
5 (10 pts)
6 (15 pts)
Total: 75
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download CS498MG Midterm Exam - Spring 2010 - Program Optimization - Prof. Maria J. Garzaran and more Exams Computer Science in PDF only on Docsity!

CS498MG

Program Optimization Spring 2010 Midterm Exam NOTE: This is a closed book exam. If you have doubts, or a question is ambiguous, please make a reasonable assumption and state it. Name: Problem No. Score 1 (15 pts) 2 (15 pts) 3 (10 pts) 4 (10 pts) 5 (10 pts) 6 (15 pts) Total: 75

2.- [Data Dependences and loop distribution] (15 pts) Indicate the dependences between the statements in the loop below. Use the notation presented in class to show flow dependences, anti-dependences and output dependences. (10 pts) for (int i = 0; i < 1024; i++) { S1: a[i] = b[i]; S2: c[i] = a[i] + b[i]; S3: e[i] = c[i+1]; } Is any of these dependences loop carried dependences? If so, indicate which one/s. Can you apply loop distribution to this loop? If the answer to the previous question is no, is there any transformation that can be done so that loop distribution can be applied? Justify your answer. (5 pts)

S

S

S

3.- [Data Dependences] (10 pts) Show the data dependences between the statements in this loop and indicate the ones that are loop carried dependences. (5 pts) float s = 0.0; for (int i = 0; i < 1280; i++) { S1: s += (float)2.; S2: a[i] = s * b[i]; } Is there anything transformation you can apply to remove all the dependences in this loop? If so, show the code without the dependences and explain which transformation you applied. (5 pts)

S

S

5.- Is it possible to do loop interchanging for this loop? Justify your answer. (10 pts) for (j = 0; j < N; j++){ for (i = 0; i < N; i++) { A[i, j+1] = A[i+1, j] + B; }}

  1. [Software pipelining] 15 pts Suppose the code below for (i = 0; i < N; i++) { A[i] += b[i] * constant } where the assembly code of each iteration looks something like this: Loop: load f0, 0(r1) load f2, 0(r2) mul f8, f0, f addf f10, f8, f sd f10, 0(r2) addi r1,r1, 4 addi r2, r2, bne r2, r7, loop Write the software pipelined code assuming that in the same iterations you are loading element B[i+3] and A[i+3], multiplying element A[i+2], adding element A[i+1] and storing A[i]. You need to write the loop and the prolog. You do not need to write the epilog.