ICE717 Parallel Programming

Final Examination

Summer 1999

¡¡

¡¡
1. Read below and answer the followings. "An inter-communication is a point-to-point communication between processes in different groups. The group containing a process that initiates an inter-communication operation is called the ``local group,'' that is, the sender in a send and the receiver in a receive. The group containing the target process is called the ``remote group,'' that is, the receiver in a send and the sender in a receive. As in intra-communication, the target process is specified using a (communicator, rank) pair. Unlike intra-communication, the rank is relative to a second, remote group. All inter-communicator constructors are blocking. (i) The syntax of point-to-point communication is the same for both inter- and intra-communication. The same communicator can be used both for send and for receive operations. (ii) A target process is addressed by its rank in the remote group, both for sends and for receives."

(a) What are the differences between "group" and "communicator" ?

(b) What are the differences between "intra-" and "inter-communicator" ?

(c) Local and remote groups need to be disjoint. Why ?

(d) An inter-communicator cannot be used for collective communication. What will be the reason ?


2. Answer the followings.

(a) What is the difference between blocking and non-blocking communication?

(b) What is the difference between local blocking and global blocking calls?

(c) Why do non-blocking calls need additional support functions?

3. Answer for the following sample of code.

Task 1

send ( task2, data, data-length )

receive ( task2, new-data, new-data-length )

¡¡
Task 2

send ( task1, data, data-length )

receive ( task1, new-data, new-data-length )

¡¡
(a) It works on some systems but not on others. What will be the main reason ?

(b) How should the code be changed to allow it to work on any system ?

(c) To work under MPI without changing the order of any calls?

(d) If using MPI, how could it be shortened and still work?

4. Visualize the data distributions (a-c) or the data alignments (d-g) resulting from the following statements.
 

!HPF PROCESSORS p (6), q (2,3)

REAL A1(10), A2(10,10), s, C1(5), C2(5,5), D(5,5)
¡¡
(a) !HPF DISTRIBUTE A1(CYCLIC(2)) ONTO p

(b) !HPF DISTRIBUTE A2(BLOCK,*) ONTO p

(c) !HPF DISTRIBUTE A2(BLOCK,CYCLIC) ONTO q

(d) !HPF ALIGN s WITH C1(*)

(e) !HPF ALIGN C2(:,*) WITH C1(:)

(f) !HPF ALIGN C1(:) WITH C2(:,2)

(g) !HPF ALIGN C2(:,*) WITH D(*,:)

¡¡

5. Answer the following on Pthreads condition variables.
(a) Explain how condition variable works and the advantages over using mutex.
(b) Show that if wait and signal operations are not executed atomically, then mutual execlusion may be violated.
(c) Is it possible to use the wait/signal APIs without using the mutex variable in the standard interface ?

request_t *remove_request()
{
request_t *request;

pthread_mutex_lock(&requests_lock);
request = requests;
requests = requests->next;
pthread_mutex_unlock(&requests_lock);
return(request);
}

void *consumer(void *arg)
{
request_t *request;

while(TRUE)
{

pthread_mutex_lock(&request_lock);
while (length==0)
pthread_cond_wait(&req_consumer, &request_lock);
request = remove_request();
length -- ;
pthread_mutex_unlock(&request_lock);
pthread_cond_signal(&req_producer);
process_request(request);
}
}

void add_request(request_t *request)
{
pthread_mutex_lock(&requests_lock);
request->next = requests; /* Insert at head of list */
requests = request;
pthread_mutex_unlock(&requests_lock);
}

void *producer(void *arg)
{
request_t *request;

while(TRUE)
{

request = get_request();
pthread_mutex_lock(&request_lock);
while (length>10)
pthread_cond_wait(&req_producer, &request_lock);
add_request(request);
length ++ ;
pthread_mutex_unlock(&request_lock);
pthread_cond_signal(&req_consumer);
}
}