Re: "Portable Holes" in Datatypes - A Summary

Rajeev Thakur (thakur@mcs.anl.gov)
Sun, 20 Apr 1997 14:41:50 -0500

In fact, this code is fully portable. You can open a file in any data
representation on any machine, and it will work for that file, because
no displacements are hardwired in the code. It uses what is returned
by MPI_File_get_type_extent.

Rajeev

> +-------------------------------------------+
> | 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.