Purpose
Library
libmpi.a
C synopsis
#include <pm_util.h> int mpc_flush(int option);
FORTRAN synopsis
MP_FLUSH(INTEGER OPTION)
Parameters
Description
This parallel utility subroutine flushes output buffers from all of the parallel tasks to STDOUT at the home node. This is a synchronizing call across all parallel tasks.
If the current STDOUT mode is ordered, then when all tasks have issued this call or when any of the output buffers are full:
If current STDOUT mode is unordered and all tasks have issued this call, all output buffers are flushed and put out to the user screen (or redirected).
If the current STDOUT mode is single and all tasks have issued this call, the output buffer for the current single task is flushed and put out to the user screen (or redirected).
Notes
Return values
In C and C++ calls, the following applies:
Examples
C Example
The following program uses poe with the -labelio yes option and three tasks:
#include <pm_util.h>
main()
{
mpc_stdout_mode(STDIO_ORDERED);
printf("These lines will appear in task order\n");
/*
* Call mpc_flush here to make sure that one task
* doesn't change the mode before all tasks have
* sent the previous printf string to the home node.
*/
mpc_flush(1);
mpc_stdout_mode(STDIO_UNORDERED);
printf("These lines will appear in the order received by the home node\n");
/*
* Since synchronization is not used here, one task could actually
* execute the next statement before one of the other tasks has
* executed the previous statement, causing one of the unordered
* lines not to print.
*/
mpc_stdout_mode(1);
printf("Only 1 copy of this line will appear from task 1\n");
}
Running this C program produces the following output (the task order of lines 4 through 6 may differ):
0 : These lines will appear in task order.
1 : These lines will appear in task order.
2 : These lines will appear in task order.
1 : These lines will appear in the order received by the home node.
2 : These lines will appear in the order received by the home node.
0 : These lines will appear in the order received by the home node.
1 : Only 1 copy of this line will appear from task 1.
FORTRAN Example
CALL MP_STDOUT_MODE(-2) WRITE(6, *) 'These lines will appear in task order' CALL MP_FLUSH(1) CALL MP_STDOUT_MODE(-3) WRITE(6, *) 'These lines will appear in the order received by the home node' CALL MP_STDOUT_MODE(1) WRITE(6, *) 'Only 1 copy of this line will appear from task 1' END
Related information
Subroutines: