Re: "Portable Holes" in Datatypes - A Summary
Rajeev Thakur (thakur@mcs.anl.gov)
Sun, 20 Apr 1997 14:33:12 -0500
> Date: Sat, 19 Apr 1997 17:18:45 -0700
> From: Bill Nitzberg <nitzberg@nas.nasa.gov>
>
> First, the problem. Consider creating a datatype containing only
> the first and last elements (the int and float) of the following
> filetype:
>
> +-------------------------------------------+
> | int | double | char | char | char | float |
> +-------------------------------------------+
>
> MPI does not currently provide *any* mechanism to express this
> as a *portable* datatype. Currently, the best a user can do is:
>
> int lengths[] = { 1, 1 };
> MPI_Aint disps[2];
> MPI_Datatype types = { MPI_INT, MPI_FLOAT };
>
> MPI_File_get_type_extent(fh, MPI_INT, &int_size);
> MPI_File_get_type_extent(fh, MPI_DOUBLE, &double_size);
> MPI_File_get_type_extent(fh, MPI_CHAR, &double_size);
>
> disps[0] = 0;
> disps[1] = int_size + double_size + (char_size * 3);
>
> MPI_Type_struct(2, lengths, disps, types, &newtype);
>
> MPI_Type_struct does not create a *portable* datatype, however,
> so a new datatype must be created for every open file in which
> this type is used, in addition to the one used for process memory.
>
> So, MPI_Type_struct and MPI_File_get_type_extent do not solve
> the problem, although the user can get around it, with some
> difficulty.
I don't see what the problem is. The new datatype created will work
for all files that use the same data representation. I don't
understand what "portable datatype" means, and why is one needed here.
The newtype defines the data layout in the file; that's all it does.
It's only as portable as the file data representation is. A different
datatype, of course, is needed for buftype, because that describes the
layout in memory.
Note that in MPI-1, a datatype constructed with MPI_Type_struct *can*
be used for communication in heterogeneous environments, because
datatypes describe only local data layout. The only rule is that the
type signature on the send side must match the type signature on
the receive side; holes can be of any sizes.
Rajeev