Sunteți pe pagina 1din 13

NATIONAL UNIVERSITY OF SINGAPORE

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

April/May 2002

Time Allowed: 2 Hours

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

FOUR(4)

questions and omprises

THIRTEEN(13)

2. Answer ALL questions.


3. Answer ALL questions within the spa e provided in this booklet.
4. This is an Open Book examination.
5.

Please write your Matri ulation Number Below.

MATRICULATION NO:

This portion if for examiner"s use only


Question
Q1(a,b, )
Q2(a,b)
Q3(a,b)
Q4(a,b)
Total

Max

Marks

(5,4,6) 15
(7,8) 15
(7,8) 15
(7,8) 15
60

Remark

Question 1.a (5 marks)


Give very brief answers (no more than 3-4 lines) to the following questions:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.

Write down one important di eren e between MPI and PVM.


(0.5)
What is a semaphore?
(0.5)
What is the di eren e between MPI_Send and MPI_Isend?
(0.5)
What is the main di eren e between \stati " and \dynami " task assignments. (0.5)
Name an edge dete tion algorithm used in image pro essing.
(0.5)
What is the meaning of \tstartup " and \tdata " in time omplexity analysis of parallel
programs?
(0.5)
When are \blo ks" better than \strips" in a syn hronous omputation solution for
Heat Distribution Problem?
(0.5)
Compare \threads" with UNIX \heavyweight" pro esses.
(0.5)
Whi h of the following languages MPI, PVM, Java, PThreads are based on message
passing ommuni ation?
(0.5)
Name a distributed termination dete tion algorithm.
(0.5)

Question 1.a . . . ( ontinuation)

Question 1.b (4 marks)


In the le ture dedi ated to the pipeline te hnique a pipeline algorithm to sort numbers was
presented. Apply the algorithm to sort in reasingly the following sequen e 2,5,3,6,1,4.
(Des ribe the steps.)

Question 1. (6 marks)
A parallel version of Moore algorithm (denoted by PMoore here) for single-sour e shortest
path problem using de entralized work pool method was presented in the le tures. Apply
PMoore to nd the shortest path from 1 to 7 in the following weighted graph G:
|G has seven verti es denoted by numbers from 1 to 7.
|The weights of the edges are: w12 = 1; w23 = 2; w34 = 3; w14 = 7; w45 = 3; w56 =
2; w67 = 1; w47 = 7 and the other edges have weight 0.

Question 2.a (7 marks)


Let n and p be positive natural numbers. Implement a barrier a ting a ording to the
following rules:
|the master pro ess 0 a epts to re eive a knowledgments of arrival to the barrier from
pro esses 1 to n in any order;
|if p pro esses from 1 to n arrive to the barrier, the master pro ess release them and
ontinue;
|the nal group of pro esses may have less than p items; the master release them after
the arrival of the last pro ess.
(Use MPI-like pseudo- ode notation; when your notation is not standard explain its meaning.)

Question 2.b (8 marks)


Let us onsider the following shared-memory program (for binomial oe ients ( ) =
 ( +1) ):
1 
n
k

n :::

::: k

input vars n,k:


lo al vars y1,y2:
output vars z:
l0:: while y1 > n l1:: z := z * y1
l2:: y1:= y1 - 1
od

integer,
integer,
integer,
k do

initially 0 =< k =< n;


initially y1=n, y2=1;
initially z=1
||
m0:: while y2 =< k do
m1:: await y1 + y2 =< n
m2:: z := z / y2
m3:: y2 := y2 + 1
od

[l0,. . . , m0, . . . are the labels of the statements; await(b) blo ks the pro ess until ondition b is satis ed; || denotes parallel exe ution.
1. Des ribe two possible runnings for (53 ) on a single pro essor (use sequen es of labels
l0,. . . , m0, . . . to spe ify them | the assignment and test statements are onsidered
to be atomi here).
(5)
2. Is await statement m1 ne essary? What happens if it is deleted from the program?
(3)

Question 3, Problem Par


Problem Par: Find the rst o urren e of the sequen e \parallel" in a text represented
as an array of 256 hara ters.

Question 3.a (7 marks)


Des ribe a parallel divide-and- onquer algorithm to solve problem Par using 16 pro esses.
Present the steps in words (no ode).

Question 3.b (8 marks)


Give an implementation of your algorithm for solving problem Par (Q3) using MPI-like
pseudo- ode notation.

Question 3.b . . . ( ontinuation)

10

Question 4.a (7 marks)


Let us onsider a network N (k ) with the following topology: a omplete binary tree with
k levels having the leaves onne ted in a ring network. (See the pi ture for an example.)

S
 S

S
S

S
 S

(2) =




S
S

S
 S

S

1. Find the diameter of N (k ) for k  1.


2. Find the average distan e between 2 vertexes of N(2).

11

S
(4)
(3)

Question 4.b (8 marks)


1. Des ribe a sequential algorithm for sear hing the rst o urren e of a number in a
list and analyze its time omplexity.
(4)
2. Propose a parallel algorithm for the same problem and analyze its time omplexity.
(4)

12

Question 4.b . . . ( ontinuation)

End-Of-Paper

13

S-ar putea să vă placă și