B424 Parallel and Distributed Programming

Homework 3

Due date: Tuesday, September 28, 2004.


Ex. 1 Download the following files.
find_min.cc
find_min.h
main.cc
Makefile

Compile the program with the command make. The name of the executable will be find_min.

a. Implement of the function Input_array. This function should allocate an array with the given size for each process. Each process inputs their own part of the array in order. Process 0 can start to input the numbers from the user right away. Each process except for 0 should wait for a message from the previous process telling them when their time to start the input has come. After they are done, each process except for the last one should send a message to the next process telling them to start the input. Each process should output their id just before they start asking the user for numbers.

Replace the call to the function Generate_array in the Initialize_array with the function Input_array.

b. Write the code for the function Find_global_min_lnp which must implement a hierarchical data collection as seen in class. In this function, make sure that each process outputs the value they have for the minimum and that the process 0 outputs the value of the global minimum.

Replace the call to the function Find_global_min with Find_global_min_lnp.