INTRODUCTION
The ability to transport datatype and communicator internal structure
is of interest in servers, middleware, and one-sided communication.
A specific example are parallel IO servers.
This proposal adds new functionality to MPI_Pack_size, MPI_Pack, MPI_Unpack,
and MPI_Comm_compare but otherwise proposes ``no new functions''.
It does not attempt to be a panacea for heterogeneous datatype transport,
but instead provides a mechanism for transport when solutions are
straightforward to implement.
When a user's data is packed along with a packed communicator and
packed datatype, the resulting compound packed object is a transportable
self-describing structure. The communicator information can be used
by other servers to determine if the numeric formats are readable or
in a network (XDR) format. The datatype information can be used
to dynamically instantiate a memory container for the data and
apply collective communication operations on the object. Not all
datatypes can be re-instanted on all systems in a meaningful way.
The ability to store the communicator and datatype conditions at
the time of origination will help users (and tools) determine the
extent of transport limitations.
PROPOSAL
Packed representation of a datatype. When an MPI implementation
produces a ``flat'' (packed) representation of a datatype at the user
level, it will be in the format described in Table I [see page 150,
4/22/96 draft of MPI-2]. The binary encoding will be 8-bit ASCII
character, suitable for storage as a Fortran array of MPI_BYTE.
Packed representation of a communicator. When an MPI implementation
produces a ``flat'' (packed) representation of a communicator at the
user level, it will be in the format described in Table II [TBD by
external group]. The binary encoding will be 8-bit ASCII character,
suitable for storage as a Fortran array of MPI_BYTE.
Size of packed representations. A packed representation of a derived
datatype or a communicator is dynamic in length. Hence, for users
to allocate buffer space for a packed {datatype, communicator}, they
will need to determine the length at run-time. This can be achieved
with MPI_Pack_size, in the same manner that MPI-1 determines the
length of packed user data. Specifically, for:
MPI_Pack_size(incount, datatype, comm, size, (ierror))
IN IN IN OUT
incount datatype comm size
-------------------------------------------------------------------------
1 valid datatype MPI_COMM_NULL length of packed datatype
1 MPI_DATATYPE_NULL valid communicator length of packed comm
any>0 valid datatype valid communicator MPI-1 definition
The MPI_DATATYPE_NULL macro is introduced here [see Using MPI, p. 51].
Advice to implementors. A packed representation of these otherwise
opaque objects could be produced internally either at the time the
object is committed or when MPI_Pack_size() is called.
Packing datatypes and communicators. Once the length of a packed object
is known, the user can allocate buffer space and then call MPI_Pack:
MPI_Pack(inbuf, incount, datatype, outbuf, outcount, pos, comm, (ierror))
IN IN IN IN OUT
inbuf incount datatype comm outbuf
-------------------------------------------------------------------
any/NULL 1 valid datatype MPI_COMM_NULL packed datatype
any/NULL 1 MPI_DATATYPE_NULL valid comm packed comm
some buf any>0 valid datatype valid comm MPI-1 definition
The inbuf argument is extraneous when packing datatypes and communicators.
Hence, it can be NULL in C and an arbitrary MPI_Aint in Fortran.
Remaining arguments are as defined by MPI-1. Some Fortran compilers
do not support any memory allocation functions. Users of these systems
will either have to (a) maintain a suitably large MPI_BYTE array
for buffer space and compare it's length to the size returned by
MPI_Pack_size, or (b) write/obtain their own fmalloc wrapper to a
C malloc, or (c) go without the use of MPI_Pack.
Unpacking communicators. Given a packed communicator, MPI_Unpack will
instantiate it in an MPI_Comm object. {\em The use of an unpacked
communicator is undefined except in the comparison to other communicator
objects\/}.
MPI_Unpack(inbuf, insize, pos, outbuf, outcount, datatype, comm, (ierror))
IN IN IN/OUT OUT
outcount datatype comm outbuf
--------------------------------------------------------------------------
1 MPI_DATATYPE_NULL spare comm object any/NULL
any>0 valid datatype valid communicator MPI-1 definition
The outbuf argument is extraneous when unpacking communicators.
It can be NULL in C and an arbitrary MPI_Aint in Fortran.
The user needs to declare the IN/OUT comm object in their code;
e.g., MPI_Comm comm_extern. It must be free at the time of use.
Remaining arguments are as defined by MPI-1.
Comparing communicators. Given a local and an external (unpacked)
communicator, the user would like to compare attributes of the two
objects which are possibly separated in both space and time.
MPI_Comm_compare(comm1, comm2, result, (ierror))
Context Group Arch Format Result
-----------------------------------------------------------------
Same Same Same MPI_IDENT *
Same Same MPI_CONGRUENT *
Same Same MPI_SIMILAR *
-----------------------------------------------------------------
Same MPI_ARCH_EQUIV +
MPI_UNEQUAL +
Same Same MPI_UNEQUAL +
Same MPI_UNEQUAL +
Same MPI_UNEQUAL +
-----------------------------------------------------------------
* equivalent to MPI-1 definition.
+ proposed extension.
``Same'' architecture format means that the implementation recognizes
the architecture format and can perform in-transit translation
of data from one communicator CPU to the other. Implementations are
only required to recognize their own architecture version (at compilation
time) and XDR network format.
Unpacking datatypes. Given a packed datatype, MPI_Unpack will allocate
memory for the data and commit the data structure(s) to an MPI_Datatype
object. {\em The use of an unpacked datatype is undefined when the
datatype contains MPI derived types which only specify memory
displacements\/}.
MPI_Unpack(inbuf, insize, pos, outbuf, outcount, datatype, comm, (ierror))
IN IN/OUT IN OUT
outcount datatype comm outbuf
--------------------------------------------------------------------------
1 uncommitted datatype MPI_COMM_NULL any/NULL
any>0 valid datatype valid communicator MPI-1 definition
The outbuf argument is extraneous when unpacking datatypes.
It can be NULL in C and an arbitrary MPI_Aint in Fortran.
The user needs to declare the IN/OUT datatype object in their code;
e.g., MPI_Datatype type_extern. It must be free at the time of use.
Remaining arguments are as defined by MPI-1.