[mpich-discuss] MPI_Datatype for a structure containing pointers
Jed Brown
jedbrown at mcs.anl.gov
Mon Feb 4 07:23:00 CST 2013
On Mon, Feb 4, 2013 at 3:45 AM, Aya Aya <aya_tounsi at hotmail.fr> wrote:
> I want to send (scatter) an array of N element of the structure below,
> with sizeof(Tab)=T
>
> struct bloc
> {
> int T;
> double *Tab;
> };
> typedef struct bloc BLOC;
>
> I wonder if it is possible to create a new MPI_Datatype for this structure
> (the size of Tab depends on T), or the only way is to sent it as an array
> (using Scatterv).
>
You can create a datatype for one particular instance of this structure
(fixed location of the array and fixed size T), but not a "dynamic
datatype" that sends any instance of this struct. There is not an
MPI_Scatterw, however, so you have to pack a homogeneous buffer yourself.
Since you can't allocate on the receiver without knowing the size T, do an
MPI_Scatter of the sizes T (if you don't somehow know this already),
allocate, and do an MPI_Scatterv out of a single packed array (containing
the concatenation of all the Tabs).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mpich.org/pipermail/discuss/attachments/20130204/d264f092/attachment.html>
More information about the discuss
mailing list