IBM Books

MPI Programming Guide

MP_FLUSH, mpc_flush

Purpose

Flushes task output buffers.

Library

libmpi.a

C synopsis

#include <pm_util.h>
int mpc_flush(int option);

FORTRAN synopsis

MP_FLUSH(INTEGER OPTION)

Parameters

option
is an AIX file descriptor. The only valid value is:

1
to flush STDOUT buffers.

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:

  1. all STDOUT buffers are flushed and put out to the user screen (or redirected) in task order.
  2. an acknowledgement is sent to all tasks and control is returned to the user.

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:

0
indicates successful completion

-1
indicates that an error occurred. A message describing the error will be issued.

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):

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:


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]