Exercises for Chapter 5 ”Analytical Modeling of Parallel

Exercises for Chapter 5 ”Analytical Modeling of
Parallel Programs”
March 11, 2013
Exercise 1
If a problem of size W has a serial (non-parallelizable) component Ws , prove
that W/Ws is an upper bound on the obtainable speedup, no matter how many
processing elements are used.
Exercise 2
Scaled speedup is defined as the speedup obtained when the problem size W is
increased linearly with the number of procoessing elements p. That is, if W is
chosen as a base problem size for a single processing element, then
Scaled speedup =
pW
.
TP (pW, p)
For the problem of adding n numbers on p processing elements (Example 5.1
in the textbook), plot the speedup curves, assuming tat the base problem for
p = 1 is that of adding 256 numbers. Use p = 1, 4, 16, 64 and 256. Assume
that it takes 10 time units to communicate a number between two processing
elements, and that it takes one unit of time to add two numbers. Now plot
the standard speedup curve for the base problem size and compare it with the
scaled speedup curve.
Hint: The formula for the parallel runtime TP is (n/p − 1) + 11 log p.
Exercise 3
Write an MPI program that first uses a master process to read in a JPEG image.
(The existing C code collection http://heim.ifi.uio.no/xingca/inf-verk3830/simple-jpeg.tar.gz
can be used.) Then the master process divides the image and distributes the
pieces to the other MPI processes. The purpose is to involve all the MPI processes to calculate the average pixel value of the entire image, and the standard
deviation value.
1
Exercise 4
Suppose a 2D uniform grid is divided into P × Q rectangular pieces. Each piece
is assigned to one MPI process, and that two and two neighboring processes
(in both x- and y-direction) need to exchange the values on their outermost
boundary-layer points. Can you make use of the following two MPI functions:
MPI Type vector and MPI Type commit
to help simplify communications in the x-direction?
Hint: You should make use of an online MPI manual.
2