Figure 2: An example of nine processors arranged in a two-dimensional torus.
Each processor stores its rank in MPI_COMM_WORLD in an integer
variable and in a float variable. Depending on the choice of user (for example,
a #define statement in the program), each process should compute and print
either the row sum or the column sum of these values along the row or the
column where it belongs.
For example, in the case of Figure 2, the row sums would be
9, 9.0 for processes 0, 3, and 6,
12, 12.0 for processes 1, 4, and 7,
15, 15.0 for processes 2, 5, and 8
whereas the column sums are
3, 3.0 for processes 0, 1, and 2,
12, 12.0 for processes 3, 4, and 5,
21, 21.0 for processes 6, 7, and 8.
Make an MPI-program utilising two-dimensional virtual cartesian process topology and derived datatypes which implements this. Let MPI initialize the number of processes in each dimension of the process grid. This can be made using MPI_Dims_create.
The case of one-dimensional ring topology is implemented in " ringtopo.c". This may be used as a starting point.
You may need the following MPI-routines: MPI_Init, MPI_Comm_rank, MPI_Comm_size, MPI_Dims_create, MPI_Cart_create, MPI_Cart_shift, MPI_Address, MPI_Type_struct, MPI_Type_commit, MPI_Issend, MPI_Recv, MPI_Wait, MPI_Finalize