IBM Books

MPI Subroutine Reference

MPI_BUFFER_DETACH, MPI_Buffer_detach

Purpose

Detaches the current buffer.

C synopsis

#include <mpi.h>
int MPI_Buffer_detach(void* buffer,int *size);

C++ synopsis

#include mpi.h
int MPI::Detach_buffer(void*& buffer);

FORTRAN synopsis

include 'mpif.h' or use mpi
MPI_BUFFER_DETACH(CHOICE BUFFER,INTEGER SIZE,INTEGER IERROR)

Parameters

buffer
is the initial buffer address (choice) (OUT)

size
is the buffer size in bytes (integer) (OUT)

IERROR
is the FORTRAN return code. It is always the last argument.

Description

This subroutine detaches the current buffer. Blocking occurs until all messages in the active buffer are transmitted. Once this function returns, you can reuse or deallocate the space taken by the buffer. There is an implicit MPI_BUFFER_DETACH inside MPI_FINALIZE. Because a buffer detach can block, the impicit detach creates some risk that an incorrect program will hang in MPI_FINALIZE.

If there is no active buffer, MPI acts as if a buffer of size 0 is associated with the task.

Notes

It is important to detach an attached buffer before it is deallocated. If this is not done, any buffered message may be lost.

In FORTRAN 77, the buffer argument for MPI_BUFFER_DETACH cannot return a useful value because FORTRAN 77 does not support pointers. If a fully portable MPI program written in FORTRAN calls MPI_BUFFER_DETACH, it either passes the name of the original buffer or a throwaway temp as the buffer argument.

If a buffer was attached, PE MPI returns the address of the freed buffer in the first word of the buffer argument. If the size being returned is 0 to 4 bytes, MPI_BUFFER_DETACH will not modify the buffer argument. This implementation is harmless for a program that uses either the original buffer or a throwaway temp of at least word size as buffer. It also allows the programmer who wants to use an XL FORTRAN POINTER as the buffer argument to do so. Using the POINTER type will affect portability.

Errors

MPI not initialized

MPI already finalized

Related information

MPI_BSEND
MPI_BUFFER_ATTACH
MPI_IBSEND


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