Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: Re: [OMPI users] Similar question about MPI_Create_type
From: Jed Brown (jed_at_[hidden])
Date: 2010-02-08 14:11:49


On Mon, 08 Feb 2010 13:54:10 -0500, Prentice Bisbal <prentice_at_[hidden]> wrote:
> but I don't have that book handy

The standard has lots of examples.

  http://www.mpi-forum.org/docs/docs.html

You can do this, but for small structures, you're better off just
packing buffers. For large structures containing variable-size fields,
I think it is clearer to use MPI_BOTTOM instead of offsets from an
arbitrary (instance-dependent) address.

[...]

> if (rank == 0) {
> a_point.index = 1;
> a_point.coords = malloc(3 * sizeof(int));
> a_point.coords[0] = 3;
> a_point.coords[1] = 6;
> a_point.coords[2] = 9;
> }
>
> block_lengths[0] = 1;
> block_lengths[1] = 3;
>
> type_list[0] = MPI_INT;
> type_list[1] = MPI_INT;
>
> displacements[0] = 0;
> MPI_Address(&a_point.index, &start_address);
> MPI_Address(a_point.coords, &address);
                ^^^^^^^^^^^^^^

Rank 1 has not allocated this yet.

Jed