[Mpi3-bwcompat] MPI_Count mixing with int...
Fab Tillier
ftillier at [hidden]
Wed Jul 7 01:23:07 CDT 2010
I'm going through the spec looking at examples that need updating, and came across example 4.22, which shows an interesting pattern that we may need to consider.
Page 125, line 23, the call to MPI_Pack returns the postion as an output. This parameter is defined as an int in the standard. We thus can't type the position variable as an MPI_Count, otherwise taking the address and treating it like an int could leave some uninitialized bits.
Then, on line 27, the buffer is sent, and position is used as the count of bytes, and in this case should be of type MPI_Count. Granted, in C the type will be promoted to MPI_Count, but there are subtle issues.
I'll assert the following:
1. These two types should match.
2. The 'position' parameter to MPI_Pack and MPI_Unpack shouldn't be integers.
3. This should be extended to apply to the 'size' parameter to MPI_Type_size and MPI_Pack_size, which shouldn't be integers. This also applies to MPI_Pack for outsize, and MPI_Unpack for insize.
While we could treat the second issue separately, the fact that the output parameter from MPI_Pack can be used as input to MPI_Send would suggest the two are fairly closely coupled:
it doesn't make sense to have the range of the position type to MPI_Pack exceed the range of the count type to MPI_Send. The reverse could apply to MPI_Recv followed by MPI_Pack, thus MPI_Count shouldn't be greater in range than int or you could receive more than an integer's worth of MPI_PACKED data, and be unable to unpack it. Using these two parings {MPI_Pack, MPI_Send} and {MPI_Recv, MPI_Unpack} supports my first assertion above.
Would anyone object if we defined MPI_Size rather than MPI_Count, and used it for count, position, and size parameters? We could then tackle the issues with MPI_Pack/Unpack/Pack_size/Type_size at the same time as counts. We can't use MPI_Aint here since we want to be able to be backward compatible, so must provide a separate type that can be defined as a standard integer.
Thoughts?
-Fab
P.S. anyone feel like owning fixing the examples in the standard?
More information about the Mpi3-bwcompat
mailing list