next up previous
Next: Performance Considerations with User-Defined Up: Portability Issues Previous: Non-standard Send Modes

Standard I/O

MPI does not require that standard I/O work as expected from MPI applications. For instance, data written to stdout in a C program may be heavily buffered or may be lost entirely. Implementations that use rsh for starting remote processes and handling remote standard I/O typically have problems with buffering, so that output may not appear until long after it is written. At least one implementation (SGI) currently does not handle output from remote nodes, though that will be changed in the next release. Many implementations do not provide line buffering, so that output from several processors can become intermixed and garbled.

An MPI application can inquire about regular I/O facilities by looking at the MPI_IO attribute. Technically, this allows one to write portable programs that use standard I/O, but it is painful to use and not helpful if the answer is ``no.''

Because of the importance of standard output for MPI usability (especially for debugging), it is the opinion of this reviewer that when standard output is normally available (i.e., for serial programs) high quality MPI implementations should provide standard output, without line garbling, and with little delay between when the output is written and when it appears on the terminal. Furthermore, it is not unreasonable for applications to rely on this ability, though they should not expect high performance.

Input is a different issue. When a parallel application reads from standard input, to which process should the input go? Some implementations direct standard input to process 0 in MPI_COMM_WORLD. This is what users often expect, though not all implementations allow it to work. Some implementations provide the optional ability to broadcast the input to all processes, with the requirement that all processes read the same data. When possible, applications should avoid reading from standard input, choosing instead to open files. When reading from a file is necessary, the most portable option is to read it only on process 0 of MPI_COMM_WORLD, but do not expect this to always work.


next up previous
Next: Performance Considerations with User-Defined Up: Portability Issues Previous: Non-standard Send Modes

Jack Dongarra
Sun Nov 9 14:03:51 EST 1997