next up previous
Next: eighth.c in detail Up: Lesson 5 -- Previous: Compiling and running

The discussion of output

After the usual stuff written by the preamble we have an interesting listing of processes reorganised into the new Cartesian communicator. Each process spells its rank number in MPI_COMM_WORLD, which is followed by their new rank number in the Cartesian communicator. You can see that in our case they are identical, but it is important to remember that they don't have to be. You should also notice that one of the processes, process rank 12, which runs on vesta, was left out of the Cartesian communicator.

Each process spells its own Cartesian coordinates, identifies its left, right, top, and bottom neighbours and prints their Cartesian communicator rank numbers. For example process number 4, which runs on mars, has Cartesian coordinates (1, 1), and its neighbours are process 3 (1, 0) on the left, process 5 (1, 2) on the right, process 7 (2, 1) above, and process 1 (0, 1) below.

Note that what is above and below is very much left to our own interpretation. Here we have organised processes and matrices in such a way that they can be mapped onto an grid with y coordinate pointing upwards. That's why our row number 0 is at the bottom, not at the top of the process space.

This should become clearer further down, where all processes contribute their small matrices to the display matrix of the master process. You can see process 0 sending a matrix of zeros. Process 1 contributing its matrix of ones, and so on.

Now we perform our first communication operation, and display the results. It looks like the processes exchanged top and bottom rows of their matrices with their top and bottom neighbours. To be exact, they are not really top and bottom rows of the matrices, but rows number 1 and 2, which correspond to the top and the bottom of the interior of the matrices, that have been exchanged. If this sounds confusing, read on, I'll explain it in more detail in the next section.

Finally we perform the second communication operation, and display the results. This time the processes exchanged columns 1 and 2 with their left and right neighbours. Observe that after the rows and columns have been exchanged, each process has the data pertaining to all its neighbours in the edge rows and columns of its matrix. It can therefore perform mathematical operations which require consulting the neighbours, such as averaging over the neighbourhood, for example, which is the essence of Laplace equation.



next up previous
Next: eighth.c in detail Up: Lesson 5 -- Previous: Compiling and running



Zdzislaw Meglicki
Tue Feb 28 15:07:51 EST 1995