Final Examination
Summer 1999
¡¡
(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.
(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.
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.
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(*,:)
¡¡
(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)
{
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)
{