



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Exam; Professor: Rajopadhye; Class: Parallel Programming; Subject: Computer Science; University: Colorado State University; Term: Fall 2007;
Typology: Exams
1 / 6
This page cannot be seen from the preview
Don't miss anything!




Name
Please read these instructions completely before proceeding. Do not turn this page until you are asked to. This is a closed book exam. You are allowed to bring in one page of notes. There are five questions of equal weight. Please answer all the problems.
Prob. No. Max score Your Score 1 10 2 10 3 10 4 10 5 10 Total 50
For each of the following code fragments, use OpenMP pragmas to make the loop parallel, or explain why it is not suitable for parallel execution. If it is not parallelizable, suggest how the program could be rewritten in order to be executed in parallel.
Problem 1: [10 pts]
s = 0; for (i=0; i<n; i++) s += a[i] * b[i];
for (i=0; i<n; i++) for (j=0; j<m; j++) { X[j] = bar(X[j], X[j-1]); /* bar has no side-efffects */ }
for (i=0; i<n; i++) for (j=0; j<m; j++) { X[i] = bar(X[i], X[i-1]); /* bar has no side-efffects */ }