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: Prentice Bisbal (prentice_at_[hidden])
Date: 2010-02-08 14:42:15


I hit send to early on my last reply, please forgive me...

Jed Brown wrote:
> 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

Thanks, I'll check out those examples.
>
> 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.

I'll give that a try, too. IMHO, MPI_Pack/Unpack looks easier and less
error prone, but Pacheco advocates using derived types over
MPI_Pack/Unpack.

>
> [...]
>
>> 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.

I'm glad you brought that up. I wanted to ask about that:

In my situation, rank 0 is reading in a file containing all the coords.
So even if other ranks don't have the data, I still need to create the
structure on all the nodes, even if I don't populate it with data?

Thanks for the help.

-- 
Prentice