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

The synopsis of first.c

Program first demonstrates the use of MPI inquiry functions, and the use of point to point communications as well as the use of broadcast. The purpose of the activities within this program is to configure one of the nodes as the one through which all messages will be written to your VDU.

Text written using printf on nodes other than the node from which LAM was started are sent to /dev/null. Only text printed on the local node will appear on your display. This behaviour is LAM specific. MPICH, for example, channels output from all nodes to the window from which the job was started. PVM based UNIFY, on the other hand, writes standard output to special files which PVM creates automatically in /tmp. On other systems some nodes may not support any I/O at all, and there may be one predefined host node.

Our job is to find out if there is a predefined host node and redirect all information from other nodes to that host, if there is. If there is no host, we should check which nodes can do I/O at all, and select one of those nodes as our host. Finally, if there is no host and if all processes can do I/O we have to determine our host in some other way. For example we can take the name of the host from the command line. The possibility that there is no host and that no processes can do I/O is too horrible to contemplate. A system like that would be useless anyway.

Once we have determined, which of the processes is going to channel the I/O, we have to inform all other processes about our choice. When other processes know where to send the information they send homage to the master process, which redirects the messages to stdout.



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



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