Re: 3rd party datatype instantiation
Robert George (george@cs.nps.navy.mil)
Mon, 6 Nov 1995 06:24:40 -0800
On Nov 3, 5:53pm, Steve Huss-Lederman wrote:
> Subject: Re: 3rd party datatype instantiation (was: mpi-io, mpi-dynamic ge
> The question was asked as to why STRUCT is included in the list of
> restricted types that can be sent portably around machines. It is
> not, as far as I know, to deal with 32 vs. 64 bit word sizes. When
> you reuse a datatype on a node with a different word size, it will
> automatically get the new data size. The issue is a struct may be a C
> struct like:
>
> struct test {
> int i;
> char c;
> int j
> };
>
> Different machines may use different padding schemes for the char.
> They may work align them all or not. It may depend on compiler
> options. Thus, the receiver can reproduce the struct on the sender
> but this may differ from the struct on the reciever. The problem is
> that MPI_TYPE_STRUCT has an array_of_displacements. Once you create
> the MPI struct to represent the C struct, you lose the high level
> information which would allow the system to change the displacements
> accordingly.
>-- End of excerpt from Steve Huss-Lederman
Steve, Richard,
Raw C structures are not portable even if you have a homogeneous architecture.
Many C compilers play games with the ordering of data elements within a
structure as a means of packing data (such as grouping all the char`s together
at the end of the structure). The ANSI C specification specifically says that
they make no assumptions about how the compiler implements a C structure,
except that it must not start or end with a "hole."
The specification later says that if you don't like this, then use XDR, or the
ISO data format standard.
Robert