8

I came across this today

MPI_ERR_COUNT Invalid count argument. Count arguments must be non-negative; a count of zero is often valid.

What does it mean by a count of zero is often valid? Does it mean that it is implementation dependent?

2 Answers 2

11

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.

Sign up to request clarification or add additional context in comments.

4 Comments

+1. In short, even without a payload, the very fact that a message was received can be information enough, e.g. to signal that a certain point in execution has been reached.
but then why wouldn't it say that a count of zero is always valid? (I agree that messages without a payload are useful)
You're correct. zero is always valid. I've looked into the standard (section 3.2.2 of the MPI 2.2 standard)
The way I see it is the man page isn't the spec. It's just saying "oh, Mr Programmer, keep in mind that a zero-argument message can be valid, too"
8

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

2 Comments

I'm not sure that I understand the symmetric code argument ... Sometimes the information from the message envelope is all you need (to syncrhonize two processes for example).
Symmetric means that there are no if-s in the code and thus it is more easy to read and understand it. Another example is the use of MPI_PROC_NULL to prevent rank-specific logic in border processes in a non-periodic Cartesian topology, e.g. "if I am not the highest rank, then send a message to rank+1" or "if I am not rank 0, then receive a message from rank-1".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.