Search for question
Question

Assignment 4. Input: D0, n x n matrix with 0 on diagonal, positive values other places Output: D, n x n matrix for k starting from 0 through n-1 for i starting from 0 through n-1 for j starting from 0 through n-1 D[i][j] min{ D0[i][j], D0 [i] [k] + D0 [k] [j] } end for j end for i for i starting from 0 through n-1 for j starting from 0 through n-1 D0 [i] [j] = end for j end for i end for k D[i][j] Write an MPI code that parallelizes the pseudo code given above by parallelizing the inner for-i and for-j loops in a way that each process can allocate memories only for a sub-matrix of D and a sub-matrix of DO of size n/√P × n/√P, where P is the number of processes. You may allocate up to 4 more 1-D arrays of size n/√P. You may assign processes as in the figure below to make the parallelization easier, where the number in each small square is the process id, i.e. the rank of the process. You may assume n is divisible by √P and P is the square of a positive integer. The communication cost of your parallel algorithm should be bounded by 0 (log2 VP) √P for each k-loop iteration. 0 √P √P-1 √P+1 2√√√P-1 ?? ??+1 P-1