CS 4328 Parallel Computing Lab Exercise for Chapter 7 – Moore`s

advertisement
CS 4328 Parallel Computing
Lab Exercise for Chapter 7 – Moore’s Algorithm
Implement Moore's algorithm for shortest path described in Chapter 7. Use the distributed workpool
version. The master process (P0) should read the adjacency matrix from a text file and start the process
by examining the source (i.e., the source vertex is assigned to P0). The format of the input file should be:
n
-- the number of vertexes
The first row of the matrix, n numbers separated by spaces
…
The nth row of the matrix
Use -1 to indicate infinity in the matrix.
Once the program terminates, the master process P0 gathers the distances from other processes and
prints them on the screen.
Note: Although the number of processes to create to run each case has to be equal to the number of
vertexes in the given problem, the program should be designed as a general program that can take any
input size (the number of vertexes can differ from case to case).
Termination detection: Use P0 as the root. When a process computes a new distance to a vertex, it
sends the new distance to the corresponding process and becomes its parent. Upon receiving the new
distance, the child process determines whether an update should be done to the current shortest
distance. If no update to be done, the process sends an acknowledgement to the parent, otherwise it
updates the distance and computes new distances to nearby vertexes and activates the corresponding
processes (and becomes their parent). When the parent has received acknowledgements from all
children, it sends the acknowledgement to its parent. When the root receives acknowledgements from
all its children, it sends a termination signal to all processes.
Turn in the tested program (.c file) together with test input files in Blackboard Vista by the due date (see
the course schedule).
Download