






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







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)
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)
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; }}