You are on page 1of 11

NATIONAL UNIVERSITY OF SINGAPORE

SCHOOL OF COMPUTING
SUPPLEMENTARY EXAMINATION FOR
Semester 2: 2002/2003
CS-3211: PARALLEL AND CONCURRENT PROGRAMMING

21 MAY 2003

Time Allowed: 2 Hours

INSTRUCTIONS TO CANDIDATES
1. This examination paper ontains
printed pages.

FOUR(5)

questions and omprises

ELEVEN (11)

2. Answer ALL questions within the spa e provided in this booklet.


3. This is an OPEN BOOK examination.
4.

Please write your Matri ulation Number Below.

MATRICULATION NO:

This portion is for examiner's use only


Question
Q1(1)
Q2(1,2)
Q3(1,2)
Q4(1,2,3)
Q5(1)
Total

Max

Marks

(10) 10
(4,6) 10
(4,6) 10
(6,8,6) 20
(10) 10
60

Remark

Question 1 (10 marks)


Give brief answers to the following questions:
1. What is the di eren e between SISD, SIMD, MISD, and MIMD programs?
2. Des ribe the meaning of MPI Isend() and MPI Ire v() statements.
3. Des ribe a divide-and- onquer pro edure for multiplying two 4x4 matri es using 4 pro essors.
4. Why is the solution for triangular system of linear equations (presented in the lass) a
\Type 3" pipeline algorithm?
5. Provide an example of termination dete tion whi h is possible with the dual-pass ring
termination algorithm but not with the single-pass ring termination algorithm.
6. Compare the entralized and the de entralized load balan ing te hniques.
7. Provide features whi h dis riminate between lo ks, semaphores, and monitors.
8. What is the omplexity of parallel rank sorting using n or n2 pro essors?
9. Des ribe \red-bla k" te hnique used for parallel solving of Lapla e's equation.
10. Brie y des ribe Fourier transform and omment on its use in image pro essing.

(use ba k side, if more spa e is needed)

(blank page for Question 1.1)

(use ba k side, if more spa e is needed)

Question 2.1 (4 marks)


Let x(t) be a fun tion de ned by the series
x(t)

a0

1
X

j =1

aj os

 2jt 
T

+ bj sin

 2jt 
T

Develop an e ient pipeline solution to ompute x(t) for a series of values t0 ; t1 ; t2 ; : : :.

(use ba k side, if more spa e is needed)

Question 2.2 (6 marks)


1. Apply Cannon parallel multipli ation algorithm to the following matri es

0
0
1
1
0 2 1
2 3 1
B
 3 0 1 C
 1 0 4 C
A
A and B
1

1 2

(des ribe the steps)


2. What is the parallel time omplexity of this algorithm?

(use ba k side, if more spa e is needed)

Question 3.1 (4 marks)


Consider the following pie e of pseudo- ode, where: npro is the number of pro esses, a[max
is an array of integers with max elements, and myid is the pro ess id number (i.e., 0 for the
master and 1,2,. . . ,npro -1 for the slaves)
Master (P0)

Slave Pi (i>0)

slot = max/(npro - 1);


b ast(slot,P0);
for(i=0;i<npro ;i++)
send(&i,&a[i,Pi)
for(k=npro ;k<max;k++)f
i = k % npro ;
re v(&j,&b,Pi)
a[j = b;
send(&k,&a[k,Pi)

b ast(slot,P0);
for(j=0;j<slot;j++)f
re v(&k,&a,P0);
b = a - 1024;
send(&k,&b,P0);

for(i=0;i<npro ;i++)f
re v(&j,&b,Pi)
a[j = b;

for(k=0;k<max;i++)
print a[k;

Suppose max = 10, initially a[i = 2003 for all i = 0,..,max-1, and syn hronous send/re eive
routines are used. Questions:
1. What is the result of the exe ution when 3 pro esses (master and 2 slave pro esses) are
used?
2. What is the result of the exe ution when 4 pro esses (master and 3 slave pro esses) are
used?

(use ba k side, if more spa e is needed)

Question 3.2 (6 marks)


Let us onsider a CREW ( on urrent-read/ex lusive-write) shared-memory model, namely a
model where Berstein's onditions may be used to identify when two pro esses an exe ute
their statements simultaneously.
For ea h of the following loops nd the instan es of the body that an be exe uted in parallel
and des ribe a s hedule of these instan es that minimize the parallel exe ution time.
1. int a[100;

for(i=0; i<10; i++)


a[i = 7 + a[2*i + 3*i;

2. int a[100;

for(i=0; i<10; i++)


for(j=1; j<10; j++)
a[i+j = 2003 + a[2*i+1 - a[3*j-1;

(use ba k side, if more spa e is needed)

Question 4.1 (5 marks)


HighestPoint

Problem:

Suppose the surfa e of a planet is des ribed by the formula h(; ), where h is
the height above or below the sea level,  is the angle in the equatorial plane,
and  is the angle in the polar plan.
An example may be: h(; ) = 124  sin(2)

32  os(3) + 54  sin( + 2).

Question 4.1:
1. Develop a parallel hill- limbing message-passing algorithm for the above HighestPoint
problem. (Give an informal presentation of the algorithm here.)
2. Brie y motivate your hoi e, ompared with other possible parallel programming solutions.

(use ba k side, if more spa e is needed)

Question 4.2 (8 marks)


Implement your HighestPoint algorithm using MPI-like pseudo- ode.

(use ba k side, if more spa e is needed)

Question 4.3 (6 marks)


1. Analyze the time omplexity of your HighestPoint algorithm.
2. Provide an e ient parallelization version of your algorithm to work on a ma hine with
an arbitrary number of pro esses and analyze its time omplexity.

10

(use ba k side, if more spa e is needed)

Question 5 (10 marks)


Suppose an n  n two-dimensional torus network is given (this is an n  n mash with roundaround onne tions: the orresponding free ends of the lines/ olumns of the mesh are onne ted).
1. Modify the optimal mash broad asting algorithm in order to obtain an
asting algorithm for this torus.

optimal

broad-

2. Find the diameter of a network Nk whi h is an n  n two-dimensional torus (n > 1) with


k edges missing, for k 2 f1; 2; 3; 4g.
3. Modify your broad asting algorithm for torus to get a broad asting algorithm for this
\faulty" network Nk and he k its optimality.

End-Of-Paper

11

(use ba k side, if more spa e is needed)

You might also like