LAM/MPI logo

LAM/MPI General User's Mailing List Archives

  |   Home   |   Download   |   Documentation   |   FAQ   |   all just in this list

From: Jeff Squyres (jsquyres_at_[hidden])
Date: 2004-10-25 12:28:18


On Oct 21, 2004, at 8:27 AM, ravin sachdeva wrote:

> referring to my previous query regarding the communicaton of an array
> of structures using lam, the structure that i have is of type:
>
> struct xyz {
> int
> int
> int
> int
> int
> int
> int a[][][]
> int b[][]
> int c[]
> double
> int
> };
>
> lets assume i have 'n' such structures which i want to send to another
> process ..... do i need to use MPI_Type_create_struct ? if yes then
> what should it look like ? and further what should my MPI_Send look
> like???

Having embedded pointers in your arrays may be problematic, because
those may be randomly placed in memory (i.e., independent of the
placement of your struct in memory). So making a single memory map for
the struct and the data pointed to by your struct may be impossible.

However, if you embed the arrays in your struct, then you know that the
memory layout will be consistent every time the struct is instantiated,
and you can therefore have a single MPI datatype for both.

You might want to have a look at the LAM test suite (lamtests, on the
same download page as the LAM software) for examples of using
MPI_Type_struct. Some are arbitrarily complicated, but, for example,
the first use of MPI_Type_struct in dtyp/paktest.c seems rather
straightforward.

Also, the MPI standard itself has at least a few examples of using
MPI_Type_struct.

Hope that helps.

-- 
{+} Jeff Squyres
{+} jsquyres_at_[hidden]
{+} http://www.lam-mpi.org/