Why is MPI_Bsend() a blocking function?

54 Views Asked by At

As the following definitions show, MPI_Bsend() is a blocking MPI function. But this is against our common understanding of the word 'blocking'. So these questions arise: Are the adjectives 'blocking' and 'nonblocking' helpful in any way in describing MPI functions? If not, why do they exist in the terminology at all?

Definitions of blocking and nonblocking MPI procedures according to the standard:

An MPI procedure is nonblocking if it is incomplete and local.

An MPI procedure is blocking if it is not nonblocking.

Definitions of local and nonlocal MPI procedures:

An MPI procedure is nonlocal if returning may require, during its execution, some specific semantically-related MPI procedure to be called on another MPI process.

An MPI procedure is local if it is not nonlocal.

Definitions of incomplete and completing procedures:

An MPI procedure is called incomplete if it is not a completing procedure.

An MPI procedure is called completing if return from the procedure indicates that at least one associated operation has finished its completion stage, which implies that the user can rely on the content of the output data buffers and modify the content of input and output data buffers of such operation(s). If a completing procedure is not also a freeing procedure then the user is not permitted to deallocate the data buffers or to modify the array arguments.

So in MPI the concepts of completeness and locality are more fundamental than blocking/nonblocking concept. But why does the latter exist at all?

1

There are 1 best solutions below

4
julaine On

The usefulness of the blocking/nonblocking concept is explained in the standard (4.1, pdf) as an "advice to users" on page 15:

Advice to users. Note that for operation-related MPI procedures, in most cases incomplete procedures are local and completing procedures are nonlocal. Exceptions are noted where such procedures are defined

So the concepts exist because many functions can be described as blocking, it is essentially a shorthand.


Now why is BSend considered blocking?

It is complete because the calling rank may do whatever it wants with the buffer that it passed to the function after the function completes. Modifying it is legal. It is local because no other operation is required to complete the operation.

Contrast this with ISend, where the function returns quickly, but the send-buffer may not be used or freed yet, and the status needs to be awaited.


So is the concept useful? I would say their usefulness is describing programmer responsibilities:

local/non-local describes the behaviour of functions you need to consider if you are looking to avoid deadlocks.

complete/incomplete describes the behaviour of functions you need to consider to avoid memory-bugs.

Since you need to consider both for a correct program, it is important to know where your functions are. "Blocking" is an easy mnemonic for the most common communications like Send or BCast. Common in the sense that they appear first historically and in tutorials. If you know that a function is non-blocking you know it deviates from this model.