EASTERN MEDITERRANEAN UNIVERSITY

advertisement
EASTERN MEDITERRANEAN UNIVERSITY
COMPUTER ENGINEERING DEPARTMENT
CMPE-523 – PARALLEL PROGRAMMING
Final Exam Fall 2002/03 29.01.2003 (2 hours)
Name, Surname________________________________
Id. #__________________________________
Instructor Alexander Chefranov
Question
1
2
3
Grade
Total
Q.1. (50 points). OCCAM. Assume that 2 transputers and 2n similar processes (based
on one and the same procedure Worker) are given, n>>10. Processes (i-1)n+1,..,in must
reside in i-th transputer, i=1,2. Required pattern of interaction between processes and
their location follow:
1
n+1
1
2
n
2n
Give outline of OCCAM program (including mapping of processes and channels on
resources) realizing such system of processes taking into account that transputer has only
4 links. Assume that channels use some predefined protocol P and each i-th process
knows its number i=1,..2n.
Solution outline:
1. As far as we have many interacting processes in 2 transputers and number of
physical channels (links) is only 4, it is obvious that direct exchange between
counterparts is impossible. So, additional multiplexer-de-multiplexer (MDM)
processes are to be introduced in each these 2 transputers. These MDM processes
are to gather information from processes residing on the same transputer and to
transfer messages to corresponding MDM process in the counterpart processor.
2. MDM processes are not to lose information about source of message being
transmitted (i.e. from whom it was obtained and to whom it must be sent). For this
sake, on receiving message from i-th internal parallel process via i-th channel
(using ALT construction), MDM must add to message header – i (processsender#)- and send such a packet to counterpart MDM. Counterpart MDM, on
receiving message of structure (process#, message-itself) from the other
transputer selects internal channel with number process# and sends message-itself
part of input message to corresponding internal process. Such manipulations are
usual in networking and in telephony for organization of multiple logical channels
on restricted number of available physical channels.
3. OCCAM requires that in configuration process each processor is to be mentioned
only once and only one process may be mapped on it in the form of the procedure
call. So, collection of all user processes together with MDM process in each
transputer is to be represented by one procedure with multiple internal channels
and parallel processes. Such procedures must have only 2 or 3 parameters: input
channel and output channel for interaction between MDMs and number of process
(if necessary). These two channels are to be defined as global in configuration
process and mapped to processors links. To organize connection between
trnsputers one and the same channel must be mapped on link (output physical
channel with numbers from 0,1,2,3) of one transputer and some link of the other
transputer (input physical channel with numbers from 4,5,6,7).
Q2. (50 points). ANSI C. 2 processes P0 and P1 are to work in 2 transputers T0, T1
as follows:
xi
Hos
t
yi,zi
xi
P0
T0
P1
z1i
T1
P0 receives stream xi of real numbers, i=1,2,.. It transfers them to P1 and calculates
j
j
i 1
i 1
yj=  xi / j , zj=z1j-y2j, j=1,2,..Values z1j=  xi2 / j , j=1,2,.. are calculated by P1. Give
full C-codes in ANSI C for such processes P0, P1 and full corresponding configuration
file. Assume that xi+1 is accepted by P0 only after output of yi, zi, i=1,2,..
Solution outline:
1. Configuration file is rather simple.
2. C-files must take into account that process interacting with host on the root
transputer must obtain corresponding channels for input-output by default, so,
these 2 configuration process’ parameters (they must be first in the list of
parameters) – input and output channels are not to be got by get_param(). These
channel parameters are used implicitly when scanf(), printf() etc. functions for
input-output to host are launched.
3. One little peculiarity of this task is stream-processing: input numbers are to be
processed immediately, on fly, without receiving many of them before processing,
and immediate output of result in output stream is made. So, each input x is to be
transferred to the 2nd processor, then to be summed in ys: ys+=x, counter of
numbers j to be incremented: j++, then y=ys/j, then after obtaining z1: z=z1-y*y,
then output y,z. Second process, on receiving x, accumulates it in z1s: z1s+=x*x,
increments counter j: j++, calculates current average: z1/=j, outputs z1. No arrays
are required; any number of input values can be processed using only several cells
of RAM in each transputer.
Download