[Mpi-comments] Pt2pt messaging with MPI_PROC_NULL (and MPI_TAG_NULL, MPI_ADDRESS_NULL)

Nils Smeds nils.smeds at gmail.com
Thu Oct 21 05:35:58 CDT 2021


*Summary:*
- Suggestion to introduce MPI_TAG_NULL in the standard with an obviously
illegal value (i.e. <0)
- Explicitly allow Point-to-Point messages to have one of more of: tag
MPI_TAG_NULL, datatype MPI_DATATYPE_NULL, invalid buffer addresses
(including MPI_ADDRESS_NULL)  and communicator MPI_COMM_NULL,  if (and only
if) the corresponding send or receive argument is MPI_PROC_NULL.

*Argument:*
When writing code it is useful if it goes off with a bang when you do
something wrong. To catch matching errors in sends and receives I looked
for a MPI_TAG_NULL to use as a default value to catch cases where the tag
was not set correctly. I found that there was no such item. Referring to
the standard I found that tag values are restricted to the values
0...MPI_TAG_UB, where MPI_TAG_UB (>=32767) can be found using the
MPI_Comm_get_attr() function.

So I used my own value for MPI_TAG_NULL as -1 and coded away. However, the
MPI implementation I was using blew up when I used it in a MPI_Sendrecv
with the remote task being MPI_PROC_NULL throwing an error message "illegal
tag value", which was no surprise to me since I had set it to this value
explicitly.

The workaround is of course to put a if( PartnerTask != MPI_PROC_NULL ) {
... }   around every point-to-point call, but I find it unnecessary and
makes the code look more complex. I think that MPI_PROC_NULL was invented
for exactly this purpose, to be a transparent if(...) clause for the
operation. Is there really a need to be restrictive on datat ype, tag or
any other argument when the P2P operation is with MPI_PROC_NULL?

I would expect implementations to choose  MPI_ADDRESS_NULL be  equal to (*)
0 in C  and 0_MPI_ADDRESS_KIND in Fortran and MPI_TAG_NULL to be default
integer kind -1.

*Implementation:*
Append to section "3.10 Null processes" text along the lines of:

A call to any point-to-point messaging function with a process argument of
MPI_PROC_NULL is allowed to have any value for buffer address, data type,
tag and communicator including MPI_ADDRESS_NULL, MPI_DATATYPE_NULL,
MPI_TAG_NULL and MPI_COMM_NULL without causing an error condition in the
execution.


Insert into appendix "A1 Assorted constants"

MPI_TAG_NULL and MPI_ADDRESS_NULL


Insert into section "9.1.2 Environmental Inquiries"  (which is an odd place
where Tag values are specified in the standard):

(Line 34, end of first paragraph)  [... is also a valid value for
MPITAG_UB]. The constant MPI_TAG_NULL shall have a value outside of the
0...MPI_TAG_UB range. The value MPI_TAG_NULL is erroneous to use in any
communication unless the associated process argument is MPI_PROC_NULL.


Add to section "15.3.3 Convention for Returning Strings"

The constant MPI_ADDRESS_NULL can be used as an equivalent to the null
pointer.




/Nils Smeds
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mpi-forum.org/pipermail/mpi-comments/attachments/20211021/514a49c1/attachment.html>


More information about the mpi-comments mailing list