Hi,
I have converted the GE algorithm given in the book. Now I want to parallelize it using MPI. Can somebody please guide me how to do that. My serial version is given below:
Well, Gaussian elimination works by a succession of row operations (that is why you should make sure you understand the algorithm), so I suggest that you distribute whole rows amongst the processors.
At each step the processor with the pivot row broadcasts its row (MPI_Bcast) to all other processors which do the appropriate row operations on their own rows to eliminate the element in the pivot column.
To try and achieve load balancing, distribute the rows cyclically between processors. e.g if you had 4 processors, then
processor 0 should deal with rows 0, 4, 8, ...
processor 1 should deal with rows 1, 5, 9, ...
processor 2 should deal with rows 2, 6, 10, ...
processor 3 should deal with rows 3, 7, 11, ...
The modulo operation (%) should sort this out for you.
Partial pivoting - which you should do to avoid both algorithm failure and massive round-off problems for ill-conditioned matrices - will require some reduction operation to get the maximum absolute value in a given column (see MPI_Allreduce) and some swapping of rows, potentially rows on different processors (see MPI_Sendrecv).
I suggest that you do the row operations in the elimination stage with the augmented matrix (i.e. the RHS b[] is appended as the last column of matrix A[][]).