MPI count of zero is often valid

I think you're reading too much into it. I think it means simply that depending on the user implementation, anything from 0 a random positive integer is a valid count. It's not hard to imagine a message tag that requires no parameters.

If a message tag requires no parameters, then it is valid to send only zero (and, in fact, possibly invalid to send more than that). You have to keep in mind that no parameters is not the same thing as no data, as the message tag is a "parameter" in and of its own.


It means that any function in MPI that requires a message data size to be specified accepts zero but that doesn't mean that it would lead to correct application code.

For example, MPI_Send accepts 0 as count and will always send an empty message that carries no data but still has an envelope and that can be received by any matching MPI_Recv. On the other hand if you specify 0 as the count in MPI_Recv you will get a message truncation error for any matching non-empty message that has arrived. That is 0 is almost never a valid (from the application point of view) count value for MPI_Recv although it is perfectly acceptable for MPI.

Zeroes are widely accepted in MPI since that enables one to write more symmetric code (e.g. code without lots of if (count != 0) ...

Tags:

C

Fortran

Mpi