Re: [AMBER-Developers] MPI struct passing

From: Scott Brozell <sbrozell.rci.rutgers.edu>
Date: Sun, 25 Sep 2011 21:27:01 -0400

Hi,

In addition to what has been said so far, is this old rule of thumb:
to minimize padding order your struct data members from
largest down to smallest:
struct iddd {
  double db1;
  double db2;
  double db3;
  int it1;
};
However, alignment issues may remain and may be complicated due
to platform dependencies especially if you have pointer members.

Your last sentence is key; this could be a simple startup check
that could pick one of several alternative implementations,
but i agree with Bob that you may quickly reach a point of
diminishing returns: probably best to get a universal, simple
implementation first and then pick one popular platform and
see if a struct optimization really makes much difference.

scott

On Sun, Sep 25, 2011 at 08:13:03PM -0400, dcerutti.rci.rutgers.edu wrote:
> OK, thanks Bob and Dave for your help; I'm getting a handle on
> asynchronous communication, and making what I believe is good progress on
> the parallel implementation. I don't have any long doubles in mdgx, but I
> noticed that if you do add one then the struct becomes aligned on 16-byte
> boundaries. I will think some more and try to implement a robust
> (although perhaps not so elegant) procedure to define and pass structs.
> For now I am checking all my defined types to make sure that the length of
> the defined MPI type equals the result of sizeof().
>
> > On Sun, Sep 25, 2011, dcerutti.rci.rutgers.edu wrote:
> >
> >> However, it seems that a struct like
> >>
> >> struct iddd {
> >> int it1;
> >> double db1;
> >> double db2;
> >> double db3;
> >> };
> >> typedef struct iddd id3;
> >>
> >> will show up as 32 bytes if I do sizeof(id3) even though
> >
> > Exactly: doubles (and structs themselves) have be aligned on 8-byte
> > boundaries, so the compiler has to add padding after the first int so that
> > the double that follows it is properly aligned.

On Sun, Sep 25, 2011 at 05:47:42PM +0000, Duke, Robert E Jr wrote:
> There are alignment requirements for data types, and what you are seeing is the typical padding required to keep all the dbl's aligned properly in an array.


_______________________________________________
AMBER-Developers mailing list
AMBER-Developers.ambermd.org
http://lists.ambermd.org/mailman/listinfo/amber-developers
Received on Sun Sep 25 2011 - 18:30:02 PDT
Custom Search