Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |  

This web mail archive is frozen.

This page is part of a frozen web archive of this mailing list.

You can still navigate around this archive, but know that no new mails have been added to it since July of 2016.

Click here to be taken to the new web archives of this list; it includes all the mails that are in this frozen archive plus all new mails that have been sent to the list since it was migrated to the new archives.

Subject: Re: [OMPI users] data types and alignment to word boundary
From: Dave Goodell (goodell_at_[hidden])
Date: 2011-06-29 12:16:51

On Jun 29, 2011, at 10:56 AM CDT, Jeff Squyres wrote:

> There's probably an alignment gap between the short and char array, and possibly an alignment gap between the char array and the double array (depending on the value of SHORT_INPUT and your architecture).
> So for your displacements, you should probably actually measure what the displacements are instead of using sizeof(short), for example.
> tVStruct foo;
> aiDispsT5[0] = 0;
> aiDispsT5[0] = ((char*) &(foo.sCapacityFile) - (char*) &foo);

There's a C-standard "offsetof" macro for this calculation. Using it instead of the pointer math above greatly improves readability:

So the second line becomes:

aiDispsT5[1] = offsetof(tVStruct, sCapacityFile);