Re: [mpich-discuss] MPI_Datatype for a structure containing pointers
On Mon, Feb 4, 2013 at 3:45 AM, Aya Aya <[email protected]> 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).
participants (1)
-
Jed Brown