Download Parallel Processing Midterm Exam for CS598dhp and more Exams Computer Science in PDF only on Docsity!
Name:____________________________
cs598dhp
Parallel Processing
Midterm Exam
Due in class Tuesday, May 4, 2008
(11 pages / 8 questions total)
1. Short questions [5 pts.]
(a) A way to characterize locality of a program is the space-time product. Find the definition
of space time product and state it. How is it related to the notion of efficiency for parallel
programs? In other words, what figure of merit tends to improve when space-time product is
minimized or efficiency is maximized?
(b) List the essential features of the Von Neumann computational model
3. Locality enhancement [5 pts.] Consider the loop below.
(a) How would you transform it to enhance locality?
(b) For large values of n, what fraction of cache misses do your improved version
saves relative to the original version?
do i=1,n do j=1,n B(i,j)=A(i,j+1)+A(i-1,j)+A(i,j-1)+A(i+1,j) end do end do
4. SIMD programs [5 pts.] Consider the program
do i=1,n a(i) = b(i) + c(i) s = s + a(i) end do
(a) Translate this program into a vector version. Use only triplet notation. Do not use
intrinsic functions to represent operations.
(b) Compute the speedup, efficiency, and redundancy on an array machine assuming
n/4 PEs. Assume all floating point operations take one unit of time and ignore all
other operations including those to control the loop and those needed for
communication.
6. OpenMP [5 pts.] Parallelize (as much as possible) the following loop and present the
solution in OpenMP
do i=1,n do j=1,n k=k+p x = a(k,j) + b(j,i) c(i,j)= x + x ** 2 + a(k,j) + 1 end do end do
7. OpenMP [5 pts.] For each of the following three loop nests, specify whether or not
the outermost loop can be transformed into parallel form without changing the loop
body. If the answer is no, state the reason
(a) do i=1,n do j=1,n a(i,j) = a(i,j-1) + 1 b(i,j) = a(i,j) + a(i,j) end do end do (b) do i=1,n do j=1,n a(i,j) = a(i-1,j-1) + 1 end do end do (c) do i=1,n do j=1,n a(i,j) = a(i-1,n+1) + 1 b(i,j) = a(i-1,j) + a(i,j) end do end do
(b)
c$omp parallel private(i) c$omp pdo do i=1,n x(i)=x(i)+ end do c$omp end pdo wait x(5) = x(5) + 1 c$omp end parallel
(c)
c$omp parallel do do i=1,n a(i)=b(i+1)+b(i-1)+a(i) end do
(d)
c$omp parallel private(i,j,k,t) k=some_function() t=y+x(k) c$omp barrier j=omp_get_thread_num() x(j)=t c$omp end parallel